{"record":{"id":"0607f0260389210a","repo":"n8n-io/n8n","slug":"subnode-input-connections-are-managed-by-parent-no","errorCode":null,"errorMessage":"Subnode input connections are managed by parent node SubnodeConfig","messagePattern":"Subnode input connections are 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":131,"sourceCode":"\tupdate(config: Partial<NodeConfig>): SubnodeInstanceImpl<TType, TVersion, TOutput, TSubnodeType> {\n\t\tconst mergedConfig = {\n\t\t\t...this.config,\n\t\t\t...config,\n\t\t\tparameters: config.parameters ?? this.config.parameters,\n\t\t\tcredentials: config.credentials ?? this.config.credentials,\n\t\t};\n\t\treturn new SubnodeInstanceImpl(\n\t\t\tthis.type,\n\t\t\tthis.version,\n\t\t\tmergedConfig,\n\t\t\tthis._subnodeType,\n\t\t\tthis.id,\n\t\t\tthis.name,\n\t\t);\n\t}\n\n\tinput(_index: number): InputTarget {\n\t\tthrow new Error('Subnode input connections are managed by parent node SubnodeConfig');\n\t}\n\n\toutput(_index: number): OutputSelector<TType, TVersion, TOutput> {\n\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');","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder/node-builders/subnode-builders.ts#L113-L149","documentation":"Thrown by SubnodeInstanceImpl.input() — subnodes (e.g. tools attached to an AI Agent) cannot declare their own input connections. Their parent SubnodeConfig node owns the connection graph, so calling .input() on the subnode itself is forbidden. The method exists only to satisfy the NodeInstance interface contract.","triggerScenarios":"Calling myTool.input(0) on an instance returned by a subnode builder (e.g. tool() inside an agent's tools array), or any generic code that iterates NodeInstance objects and unconditionally reads .input().","commonSituations":"Copying a node-walking utility that assumes every NodeInstance exposes input/output targets; writing a helper that renders connection diagrams over all nodes including subnodes.","solutions":["Do not call .input() on a subnode — read inputs from its parent SubnodeConfig node instead.","Guard with a type check: if the node is a SubnodeInstance, skip the .input() call.","Restructure so subnodes are only inspected via the parent's .getConnections() / subnode aggregation API."],"exampleFix":"// before\nfor (const n of allNodes) {\n  const target = n.input(0); // throws for subnodes\n}\n// after\nfor (const n of allNodes) {\n  if (n instanceof SubnodeInstanceImpl) continue;\n  const target = n.input(0);\n}","handlingStrategy":"type-guard","validationCode":"// Before walking nodes, check whether the node is a subnode\nimport { SubnodeInstanceImpl } from '@n8n/workflow-sdk/workflow-builder';\n\nif (!(node instanceof SubnodeInstanceImpl)) {\n  const target = node.input(0);\n}","typeGuard":"function isSubnodeInstance(n: unknown): n is SubnodeInstanceImpl {\n  return n instanceof SubnodeInstanceImpl;\n}","tryCatchPattern":null,"preventionTips":["Treat subnodes as opaque — never call input/output/then/to/onError on them.","Route all connection logic through the parent SubnodeConfig node.","In generic node-walking utilities, type-guard against SubnodeInstanceImpl and skip."],"tags":["subnode","connections","workflow-builder","fluent-api"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}