fix(workflows): report the workflow n8n created when activation fails - #5644
Open
bettercalln1ck wants to merge 1 commit into
Open
bettercalln1ck wants to merge 1 commit into
bettercalln1ck wants to merge 1 commit into
Conversation
enable_workflow POSTs the workflow to n8n, then PATCHes it active. The PATCH
sat inside the handler's outer try, so both of its failure modes lied:
- a timeout or connection error escaped to `except asyncio.TimeoutError` /
`except aiohttp.ClientError`, which answer "n8n workflow add timed out" or
"Cannot reach n8n" and drop n8n_id. The workflow existed in n8n and the
operator had no id to find or remove it with.
- a non-200 PATCH was not an exception at all, so the handler returned
{"status": "success", "activated": false} with the message
"<name> is now active!" about a workflow that was not active.
Activation now runs in its own scope. Either failure returns 502 naming the
workflow n8n created, stating it exists and is inactive, and telling the
operator to activate it in n8n rather than re-running enable — which on this
branch would import a second copy instead of activating the first.
The successful path keeps its existing 200/"success"/activated contract, and a
rejected create keeps surfacing n8n's own status code.
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 #3936.
enable_workflowPOSTs the workflow to n8n, then PATCHes it active. The PATCH sat inside the handler's outertry, so both of its failure modes reported something untrue:A timeout or connection error escaped to the outer handlers:
Both read as "the import did not happen", and both discard
n8n_id. The workflow did exist in n8n, and the operator had no id with which to find or remove it — the orphan this issue describes.A non-200 PATCH was not an exception at all, so the handler fell through to:
with
activated=False. It reported success, and told the operator the workflow is now active when it was not. That half is not in the issue text but sits in the same three lines and is the more likely of the two to bite.Activation now runs in its own scope. Either failure returns 502 naming the workflow n8n created, stating that it exists and is inactive, and directing the operator to activate it in the n8n admin panel — explicitly not to re-run enable, which on this branch imports a second copy rather than activating the first:
The successful path keeps its existing
200/"success"/activated: truecontract, and a rejected create still surfaces n8n's own status code — those are different faults.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
detail != "n8n workflow add timed out"specifically — that exact string was the old, id-less answer, so the assertion fails if the outer handler ever reclaims this path.except HTTPException: raiseis added ahead of the outer handlers. It is not strictly required today (HTTPExceptionis neitherTimeoutErrornorClientError), but the new 502 is raised from inside thattryand I would rather the intent be explicit than rely on the exception hierarchy staying put.dashboard/src/— the only/enablecaller isFeatureDiscovery.jsx, which hits/api/features/{id}/enable), so no UI depends on the old shape. If you would rather this be a 200 with"status": "partial"so a caller can distinguish "created but inactive" from "nothing happened", that is a small change.