{"record":{"id":"16da1737334a66bf","repo":"n8n-io/n8n","slug":"subnode-error-handling-is-managed-by-parent-node-s","errorCode":null,"errorMessage":"Subnode error handling is managed by parent node SubnodeConfig","messagePattern":"Subnode error handling is managed by parent node SubnodeConfig","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/workflow-sdk/src/workflow-builder/node-builders/subnode-builders.ts","lineNumber":153,"sourceCode":"\t\tthrow new Error('Subnode output connections are managed by parent node SubnodeConfig');\n\t}\n\n\tthen<T extends NodeInstance<string, string, unknown>>(\n\t\t_target: T | T[] | InputTarget,\n\t\t_outputIndex?: number,\n\t): NodeChain<NodeInstance<TType, TVersion, TOutput>, T> {\n\t\tthrow new Error('Subnode connections are managed by parent node SubnodeConfig');\n\t}\n\n\tto<T extends NodeInstance<string, string, unknown>>(\n\t\t_target: T | T[] | InputTarget,\n\t\t_outputIndex?: number,\n\t): NodeChain<NodeInstance<TType, TVersion, TOutput>, T> {\n\t\tthrow new Error('Subnode connections are managed by parent node SubnodeConfig');\n\t}\n\n\tonError<T extends NodeInstance<string, string, unknown>>(_handler: T): this {\n\t\tthrow new Error('Subnode error handling is managed by parent node SubnodeConfig');\n\t}\n\n\tgetConnections(): DeclaredConnection[] {\n\t\treturn [];\n\t}\n}\n\n// =============================================================================\n// Factory Functions\n// =============================================================================\n\n/**\n * Create a language model subnode instance.\n *\n * Use this for nodes that output `ai_languageModel` connection type,\n * such as OpenAI Chat Model, Anthropic, Google Gemini, etc.\n *\n * @example","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder/node-builders/subnode-builders.ts#L135-L171","documentation":"Thrown by SubnodeInstanceImpl.onError() — error-handling wiring (.onError(handler)) is owned by the parent SubnodeConfig node. A subnode cannot independently declare an error handler, so attempting to attach one throws.","triggerScenarios":"Calling toolNode.onError(errorHandlerNode) when wiring up an AI tool; a generic post-processing pass that attaches error handlers to every node.","commonSituations":"Adding fault-tolerance to a workflow that includes tools; copying a pattern from a top-level node onto a subnode.","solutions":["Attach the error handler to the parent SubnodeConfig via .onError().","Guard the loop with a SubnodeInstanceImpl check before calling .onError().","Model error handling at the agent level rather than per-tool."],"exampleFix":"// before\ntoolNode.onError(errorHandler); // throws\n// after\nagent.onError(errorHandler);","handlingStrategy":"type-guard","validationCode":"if (!(node instanceof SubnodeInstanceImpl)) {\n  node.onError(handler);\n}","typeGuard":"function isSubnodeInstance(n: unknown): n is SubnodeInstanceImpl {\n  return n instanceof SubnodeInstanceImpl;\n}","tryCatchPattern":null,"preventionTips":["Attach error handlers at the agent level, not per-tool.","Type-guard before generic error-handler attachment loops.","Keep fault-tolerance logic in the parent SubnodeConfig."],"tags":["subnode","error-handling","workflow-builder","fluent-api"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}