/n8n-mcp-skills:n8n-error-handlingfrom n8n-mcp-skills
Configures n8n error handling so failures are loud, structured, and recoverable. Covers per-node error outputs, retry/self-healing, error-trigger workflows, and 4xx/5xx response shapes for webhook/API and unattended workflows.
Ships in n8n-mcp-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
By default, when an n8n node throws, the whole workflow halts. For an interactive run you're watching, that's fine — you see the red node and fix it. For anything unattended (a webhook API, a cron job, a queue worker, an agent tool), it's the wrong default: the caller gets a timeout or an empty 500, the operator gets no alert, and the symptom is "the integration just stopped working" with no log and no clue.
This skill is about making failures loud, structured, and recoverable — and, best case, self-healing so transient blips never reach a human at all.
The two ideas that prevent most silent failures:
| Workflow shape | Error handling posture |
|---|---|
Webhook / API (anything with Respond to Webhook) | Required. Every fallible node's error output wired; status code matches cause. |
| Scheduled / cron / queue worker / agent tool (unattended) | Required. A workflow-level error workflow, plus retryOnFail on network nodes. |
| Internal one-off you run and watch yourself | Optional. Default onError: "stopWorkflow" is fine — you'll see the red node and re-run. |
The dividing line: if anyone other than you sees the output — a downstream system, an end user, an on-call engineer — the failure has to be handled, not swallowed. If you're the only watcher and the cost of failure is "I notice and re-run", looser is fine.
This is the single most common way an n8n workflow "handles" errors while actually swallowing them. Routing a node's failure to a handler takes two changes, and doing only one looks complete but misbehaves:
onError: "continueErrorOutput" on the node. This is what creates the second output. Without it, main[1] doesn't exist no matter what you wire.connections.<node>.main[1], i.e. sourceIndex: 1) to a real handler. Without a target, the error data is emitted into the void.Get one without the other and you hit a failure mode:
| What you did | What happens at runtime |
|---|---|
onError set, error output not wired | Error data is silently discarded. Downstream doesn't fire. The dashboard shows the run as succeeded. Worst case — no error logged anywhere. |
Error output wired, onError not set | The slot never fires; the handler is unreachable. On failure the workflow just halts (default stopWorkflow). |
| Both done | Failure routes down main[1] to your handler. ✅ |
n8n_update_partial_workflow// 1) Turn on the error output (creates main[1])
{ type: "updateNode", nodeName: "HTTP Request",
changes: { onError: "continueErrorOutput" } }
// 2) Wire the error output to a handler. sourceIndex: 1 = the error output.
{ type: "addConnection",
source: "HTTP Request",
target: "Handle Error",
sourceIndex: 1 }
sourceIndex: 0 is the success path, sourceIndex: 1 is the error path. (For IF nodes the aliases branch: "true"/"false" map to index 0/1; for a generic fallible node, use the explicit sourceIndex: 1.)
Then verify. This trap doesn't surface in validate_workflow — a half-wired error output validates clean. Pull the workflow with n8n_get_workflow and confirm both halves:
onError is "continueErrorOutput".connections["HTTP Request"].main[1] contains your handler.Valid onError values:
| Value | Effect |
|---|---|
"stopWorkflow" (default) | Error halts the whole workflow. |
"continueRegularOutput" | Error item flows out the normal output. Rare, usually wrong — downstream gets error-shaped data and keeps going. |
"continueErrorOutput" | Error item flows out the separate error output (main[1]). The one you wire. |
Full failure-mode catalog, fan-in/fan-out shapes, and verification: NODE_ERROR_OUTPUTS.md.
A correctly wired error output still misses whole classes of failure. Verified on n8n 2.38.5:
| Failure | With continueErrorOutput | With continueRegularOutput |
|---|---|---|
JS error inside {{ }} (TypeError on a missing path, JSON.parse on bad input, a thrown Error, a JMESPath syntax error) | nothing fires; the field is null and items take the success path | same |
Python Code node rejected before running (blocked import, dunder access: Security violations detected) or bad return shape (list in each-item mode) | node marked failed, but the unchanged input items leave through the success output; main[1] stays empty and the execution shows success | unchanged input items pass through |
Exception while code runs (raise/throw, KeyError, NameError) | routed to main[1] as { error } ✅ | { error } item on the main output |
So an error branch alone can't guard these:
{{ $json.total !== undefined && $json.total !== null }})
and send the miss down the error path yourself.nulls.onError).retryOnFail before you wire error pathsBefore you build error branches, absorb the transient failures so they never reach those branches. On any node that calls a network service — HTTP Request, comms (Gmail/Slack/Discord), databases, AI nodes, third-party integrations — set node-level retry:
{ type: "updateNode", nodeName: "HTTP Request",
changes: {
retryOnFail: true,
maxTries: 3,
waitBetweenTries: 5000 // ms
} }
Why this comes first: a 429 or a brief upstream hiccup will retry and usually succeed on its own. The error output then fires only on real, persistent failures — so your 5xx responses and on-call alerts reflect actual problems instead of noise.
Engine limits to know: retry fires on any error (there's no per-status-code filter), maxTries caps at 5, and waitBetweenTries caps at 5000ms — so 5000 is both the max and a sensible default. See n8n-node-configuration (NODE_FAMILY_GOTCHAS.md) for node-specific notes.
A webhook-triggered workflow that responds to its caller has one rule that overrides everything else: no hanging branches. Every path — success and every error — must end at a Respond to Webhook, or the caller sits there until it times out.
Webhook (responseMode: "responseNode")
├── validate input → process → Respond (200, body)
└── (any fallible node's error output → sourceIndex 1)
→ Respond (4xx/5xx, structured error body)
→ optional: log full error privately / notify
Three things make this work:
main[1] to a single Respond node. Keeps the graph readable.options.responseCode defaults to 200 — even on error branches. This is its own silent trap (see RESPONSE_SHAPES.md and n8n-node-configuration NODE_FAMILY_GOTCHAS.md): an error branch that returns 200 with an error body looks like success to the caller's HTTP client, so their error handling never fires. Set responseCode explicitly on every Respond node.Put the checks in one IF node: one boolean condition per rule (is true), combinator and. True → your logic (200); false → a 400 Respond with a static validation_error body that echoes the expected schema, so the caller can self-correct. When the caller needs per-field messages (an LLM client, a public API), replace the IF with one Code node that loops over a schema list and returns { valid, validationError, details, requiredSchema }, with the note Why Code: IF considered — per-field messages need a loop over the schema. Both patterns, the constraint cookbook and the escaping rules are in API_WORKFLOWS.md.
A 5xx with text/plain "Internal Server Error" is technically an error response and practically useless. And not every failure is a 5xx. Match the status code to why the request failed, because the caller branches on it: their monitoring alerts on 5xx (your fault) but not 4xx (their fault), and 5xx suggests "retry" while 4xx suggests "don't".
The common mistake: wiring everything — including bad input — to one Respond that returns 500 internal_error. Now the caller can't tell their bug from your outage, and your error rates can't separate real incidents from client noise.
| Cause | Status | error code | Where it's handled |
|---|---|---|---|
| Required field missing / wrong type | 400 | validation_error | Upstream check (IF conditions / per-field validator), not error output |
| Auth missing or invalid | 401 | unauthorized | Upstream check |
| Authenticated but not allowed | 403 | forbidden | Upstream check |
| Resource ID valid in request, absent in your data | 404 | not_found | Branch on the lookup result, not its error |
| Conflicts with current state (duplicate, race) | 409 | conflict | Detect with logic |
| Caller exceeded rate limit | 429 | rate_limit_exceeded | Set Retry-After header |
| Node threw, cause unknown | 500 | internal_error | Error output path |
| Third-party API returned an error | 502 | upstream_error | Error output of the HTTP node |
| Can't process right now (downstream down) | 503 | service_unavailable | Detect specific error, hint retry |
| Third-party API timed out | 504 | upstream_timeout | Error output filtered by message |
So there are two distinct flows: 4xx is decided before the work (IF/Switch + dedicated Respond), 5xx comes out of error outputs ("we tried, it broke").
Route by cause with a Switch; one static Respond per status. Picking a status code from the error is a routing job. A Switch on the error message classifies it, and each output goes to a Respond with a fixed options.responseCode and a fixed body:
error outputs (main[1]) ─→ Switch "Classify error" (on $json.error.message)
├─ contains "INVALID_ID" → Respond 400 validation_error
├─ contains "429" → Respond 429 rate_limit_exceeded
├─ contains "timeout" → Respond 504 upstream_timeout
└─ fallback (extra output) → Respond 500 internal_error
Every status is visible on the canvas, and adding one is adding a rule. Set the Switch's options.fallbackOutput to extra, or an unmatched error is dropped and the caller hangs. A single Respond with a computed code is fine for exactly two outcomes, as one short ternary in its Response Code field. The Switch JSON is in API_WORKFLOWS.md.
The default envelope is { "error": "<code>", "message": "<human text>" } — the HTTP status already says success-vs-failure, so no ok: false flag. Never leak internals (stack traces, SQL, upstream bodies, tokens) into the response — log those privately, return a sanitized message. Correlation IDs, retry_after, validation details, and the full do-not-leak list are in RESPONSE_SHAPES.md.
Per-node outputs handle the failures you anticipated on the nodes you remembered to wire. An error workflow catches everything else: a node you forgot to wire, a crash between nodes, a whole-workflow timeout, a trigger failure. For unattended workflows this is the safety net that turns "it silently stopped" into "an alert arrived".
Build it as a separate workflow starting with an Error Trigger node. n8n invokes it with the failure context:
{
"execution": { "id": "...", "url": "...", "lastNodeExecuted": "Fetch order",
"error": { "name": "NodeApiError", "message": "...", "timestamp": 1715000000000 } },
"workflow": { "id": "...", "name": "Sync Stripe customers" }
}
Minimal version — capture → notify:
Error Trigger → Slack/email (post to #incidents; the alert text is built with expressions in the message field)
A good alert includes the workflow name, a link to the editor and a link to the failed execution, the failed node name, and the real error message (not "Workflow failed"). Field expressions and the optional "fetch the failing input via the n8n node" upgrade are in ERROR_WORKFLOWS.md.
Two traps worth flagging up front:
What the community MCP can't do: assigning the error workflow (instance default or per-workflow override) is an n8n UI setting — Workflow Settings → Error Workflow. There is no MCP tool to set it. Build the error workflow with the MCP, then tell the user the exact UI step to wire it up, and to repeat it (or set the instance default) for every unattended workflow.
| Want to do | Reality |
|---|---|
| Set a workflow's Error Workflow setting | UI only (Workflow Settings → Error Workflow). No MCP tool. Build the workflow, then hand the user the UI step. |
| Toggle other workflow settings (Save Execution Data, timezone, timeout, caller policy) | UI only. n8n_update_partial_workflow has updateSettings, but the error-workflow assignment is not reliably exposed — confirm in the UI. |
| Enable instance-wide error logging (Sentry, server logs) | Instance config, outside n8n workflows entirely. |
What the MCP can do: build the error workflow, set onError/retryOnFail on nodes (updateNode/patchNodeField), wire error outputs (addConnection with sourceIndex: 1), validate (validate_workflow, n8n_validate_workflow), auto-fix common issues (n8n_autofix_workflow), test (n8n_test_workflow), and inspect failures (n8n_executions).
| Anti-pattern | What goes wrong | Fix |
|---|---|---|
onError set but error output unwired | Error silently discarded; run shows as succeeded | Wire sourceIndex: 1 to a real handler, or revert onError to stopWorkflow so it's loud |
Error output wired but onError not set | Slot never fires; handler unreachable; workflow halts on failure | Set onError: "continueErrorOutput" |
| Webhook → process → respond, no error branch | Caller gets a timeout or n8n's generic 500 | Wire every fallible node's error output to a Respond |
Error branch returns 200 with an {error} body | Caller's client reads success; their error handling never fires | Set options.responseCode to 4xx/5xx explicitly on error Responds |
One 500 internal_error for everything | Caller can't tell their bad input from your outage | Map cause → status (4xx caller, 5xx you) |
| Catching errors in a Code node and returning them as data | Downstream processes error-shaped data and continues | Let it throw; use onError: "continueErrorOutput" + wired path |
Network node with no retryOnFail | Every transient 429/blip surfaces as a 5xx; alerts fire on noise | retryOnFail: true, maxTries: 3, waitBetweenTries: 5000 |
| A function body in a Respond's Response Code or body | the routing is hidden in a field, and a runtime error turns into a silent null | Switch on the cause → one static Respond per status |
| Unattended workflow with no error workflow | A genuine failure goes nowhere | Build an Error Trigger workflow + assign it in the UI |
| Error workflow notifies the same channel the workflows monitor | Channel down → error workflow also fails → error vanishes | Use a different channel + a Data Table fallback |
Leaking $json.error (stack/SQL/tokens) into the response | Exposes internals to callers/attackers | Log privately, return a sanitized message |
| File | Read when |
|---|---|
| NODE_ERROR_OUTPUTS.md | Wiring a per-node error output on individual fallible nodes |
| API_WORKFLOWS.md | Building/reviewing a webhook → Respond workflow, including input validation (IF conditions, per-field Code validator) |
| RESPONSE_SHAPES.md | Defining response body conventions, status codes, and what not to leak |
| ERROR_WORKFLOWS.md | Setting up the workflow-level catch-all for unattended workflows |
onError/retryOnFail are node config; NODE_FAMILY_GOTCHAS.md covers the Webhook/Respond response-code traps in depth.$json.error.message and the alert-message expressions rely on correct {{ }} syntax and $json.error access.For an API / webhook workflow:
responseMode: "responseNode"onError: "continueErrorOutput" and main[1] wiredretryOnFail: true, maxTries: 3, waitBetweenTries: 5000options.responseCode (a top-level responseCode is ignored){ error, message } — no stack traces, SQL, or tokensn8n_get_workflow: both onError and main[1] present on each fallible nodeFor an unattended (scheduled/cron/queue) workflow:
retryOnFail configuredRemember: the default is silence. Error handling is two moves — make the failure route (per-node onError + wired output, or a catch-all error workflow) and make it speak (a status code and body that tell the truth). Half a move is worse than none, because it looks done.
What SKILL.md sets; muted values are Claude Code's defaults
15 skills in this plugin
/n8n-agentsDesign n8n AI agents the right way. Use when building or editing any @n8n/n8n-nodes-langchain.* AI node — an AI Agent, LLM chain, Text Classifier, or Information Extractor — and whenever the user mentions AI agents, LLM with tools, tool calling, $fromAI, system prompts, agent memory, sessionId, structured/JSON output, output parser, RAG, vector store, a chat assistant/bot, or human-in-the-loop review. Covers Agent-vs-chain-vs-classifier choice, the model/memory/tools/outputParser slots, tool names/descriptions as prompt, structured output with autoFix, memory, RAG, human review, and chat topologies./n8n-binary-and-dataHandle files and binary data in n8n correctly. Use when working with files, images, PDFs, attachments, uploads or downloads, base64, vision/multimodal input, or when an AI agent needs a file as tool input or output — and whenever the user mentions $binary, binaryPropertyName, "read the PDF", "attach the file", "send the image", Merge losing binary, or a CDN for chat images. Covers the $binary vs $json split, reading/writing binary, keeping binary alive across transforms with Merge, the agent-tool binary boundary, and the CDN/URL requirement for chat surfaces./n8n-code-javascriptWrite, review, or debug JavaScript in an n8n Code node. Use when a Code node is already in the workflow (editing it, fixing an error, choosing its mode, making it faster), or when a new one is justified: no native node fits (check the job-to-node table in using-n8n-mcp-skills first) and the job is on the closed list — loops or recursion no node expresses, state across runs, parsing no node handles, an allowlisted library, heavy all-items work, or one short node replacing 4+ glue nodes. Covers $input/$json/$node in code, this.helpers, Luxon, SplitInBatches loops, cross-iteration data, pairedItem, per-item performance, and the "Why Code:" note. Filtering, totals, dedupe, sorting, joins, file formats and API paging have native nodes (Filter, Summarize, Remove Duplicates, Sort, Merge, Extract From File, HTTP Request): see n8n-node-configuration. EXCEPTION — for the AI-agent-callable Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode), use n8n-code-tool; it has a different runtime contract./n8n-code-pythonWrite Python in n8n Code nodes (native Python, `language` pythonNative, n8n 2.x). Use when the user explicitly wants Python in a Code node, when migrating old Pyodide/"Python (Beta)" code that used _input/_json/_node/_now, or when a Python Code node fails with NameError, "Security violations detected", "Import of standard library module … is disallowed", "__build_class__ not found", "A 'json' property isn't a dictionary", or "Python runner unavailable". Covers the only two variables (_items/_item), dict-only access, imports blocked by default, the sandbox's denied builtins, accepted return shapes, and how errors interact with onError. JavaScript is the default for Code nodes — native Python has no n8n helpers and, by default, no imports. EXCEPTION — for Python in the AI-agent-callable Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode), use the n8n-code-tool skill instead (input is _query, return must be a string)./n8n-code-toolWrite JavaScript or Python for the n8n Custom Code Tool (@n8n/n8n-nodes-langchain.toolCode) — the AI-agent-callable tool, NOT the workflow Code node. Use when building a Code Tool attached to an AI Agent, writing code that an LLM will invoke, parsing the `query` input, returning a string result, defining an input schema for structured arguments (specifyInputSchema, jsonSchemaExample, DynamicStructuredTool), or troubleshooting errors like "Wrong output type returned", "No execution data available", "The response property should be a string, but it is an object", "Cannot assign to read only property 'name'", or an AI agent that refuses to call the tool. Covers the critical differences between Code node and Code Tool: return format (string vs `[{json:{...}}]`), unavailability of `$fromAI`/`$input`/`$helpers` in the Code Tool sandbox, naming rules for AI invocation, and when to use `toolWorkflow`/HTTP Request Tool instead./n8n-expression-syntaxValidate n8n expression syntax and fix common errors. Use when writing n8n expressions, using {{}} syntax, accessing $json/$node variables, troubleshooting expression errors, mapping data between nodes, or referencing webhook data in workflows. Use this skill whenever configuring node fields that reference data from previous nodes — expressions are how n8n passes data between nodes, and getting the syntax wrong is the most common source of workflow errors. Also use when asked whether a complex expression hurts performance.npx claudepluginhub czlonkowski/n8n-skills --plugin n8n-mcp-skillsOther plugins' skills for the same job