fix(workflows): match n8n workflows by exact name and stop duplicate imports - #5554
Open
bettercalln1ck wants to merge 1 commit into
Open
bettercalln1ck wants to merge 1 commit into
bettercalln1ck wants to merge 1 commit into
Conversation
…imports Two halves of one defect. Matching (Osmantic#4191): three sites resolved a catalog entry to an n8n workflow with a substring test and took the first hit — api_workflows, _remove_workflow and workflow_executions. All 18 shipped catalog entries have a name identical to the name inside their template JSON, so the loose match bought nothing. What it cost is a user's own workflow getting picked instead: n8n's duplicate action names a copy "<name> copy", which contains the catalog name, so disabling an ODS workflow could delete the user's copy. Duplicates (Osmantic#4188): enable_workflow POSTed a new workflow every time, so re-enabling left several in n8n sharing a name — manufacturing exactly the ambiguity the matcher then had to resolve. It now activates what is already installed and reports alreadyInstalled. Fixing either alone leaves the bug: correct matching over duplicated names is still a coin flip, and de-duplicating without exact matching still deletes the wrong thing. The three existing enable tests now stub get_n8n_workflows to report nothing installed, since enable legitimately consults n8n before creating.
24 tasks
This was referenced Sep 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4191.
Fixes #4188.
Closes #4191 and #4188 — they are two halves of one defect, and fixing either alone leaves the bug standing.
Matching (#4191). Three sites resolved a catalog entry to an n8n workflow with a substring test and took the first hit:
I checked whether the loose match was load-bearing: all 18 shipped catalog entries have a
nameidentical to thenameinside their template JSON, so an exact match resolves every one of them. The substring test bought nothing.What it cost is picking a workflow the operator did not mean. There are no substring collisions within the catalog — the realistic collision is a workflow the user owns. n8n's own duplicate action names a copy
"<name> copy", which contains the catalog name, and_remove_workflowis the disable path: first-match-wins there deletes the user's copy instead of the ODS-managed workflow.Replaced with one
find_n8n_workflow()helper doing an exact, case- and whitespace-insensitive name match, used at all three sites.Duplicates (#4188).
enable_workflowPOSTed a new workflow to n8n unconditionally, so re-enabling an already-installed workflow left another copy behind, sharing a name — manufacturing precisely the ambiguity the matcher above then has to resolve. It now looks for an existing workflow by exact name first, activates that one if found, and returnsalreadyInstalled: truewithout creating anything.The two are causally linked: correct matching over duplicated names is still a coin flip, and de-duplicating without exact matching still deletes the wrong thing.
AI Assistance
AI-assisted: an AI coding assistant drafted the patch and the regression test and ran the validation recorded below. I reviewed the diff, chose the validation, and am accountable for the change.
Release Lane
release/2.6.xmainStable hotfix reason:
Changed Surface
Risk And Validation
git diff --checkrelease/2.6.xCommands/results:
Operational Change Check
Notes For Reviewers
test_find_n8n_workflow_matches_exact_name_onlyorders the list so that a first-match-wins substring search would return the user's"Daily Digest copy", then asserts the ODS workflow is returned instead. It also pins that case and surrounding whitespace still match, and that a catalog name merely containing an installed name ("Digest"vs"Daily Digest") is not a match.enable_workflownow legitimately queries n8n before creating, which theiraiohttpmocks did not model (they stubpost/patch, notget). They now stubget_n8n_workflowsto report nothing installed, which preserves their original intent — they exercise the create path. No assertion was weakened.dashboard.yml:60runs the dashboard-api suite.