{"record":{"id":"be189ccd7fe37174","repo":"n8n-io/n8n","slug":"nodes-from-fromjson-do-not-support-output","errorCode":null,"errorMessage":"Nodes from fromJSON() do not support output()","messagePattern":"Nodes from fromJSON\\(\\) do not support output\\(\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/workflow-sdk/src/workflow-builder/workflow-import.ts","lineNumber":100,"sourceCode":"\t\t\t\texecuteOnce: n8nNode.executeOnce,\n\t\t\t\tretryOnFail: n8nNode.retryOnFail,\n\t\t\t\tmaxTries: n8nNode.maxTries,\n\t\t\t\twaitBetweenTries: n8nNode.waitBetweenTries,\n\t\t\t\talwaysOutputData: n8nNode.alwaysOutputData,\n\t\t\t\tonError: n8nNode.onError,\n\t\t\t\textendsCredential: n8nNode.extendsCredential,\n\t\t\t},\n\t\t\tupdate(config) {\n\t\t\t\treturn { ...this, config: { ...this.config, ...config } };\n\t\t\t},\n\t\t\tto() {\n\t\t\t\tthrow new Error('Nodes from fromJSON() do not support to()');\n\t\t\t},\n\t\t\tinput() {\n\t\t\t\tthrow new Error('Nodes from fromJSON() do not support input()');\n\t\t\t},\n\t\t\toutput() {\n\t\t\t\tthrow new Error('Nodes from fromJSON() do not support output()');\n\t\t\t},\n\t\t\tonError() {\n\t\t\t\tthrow new Error('Nodes from fromJSON() do not support onError()');\n\t\t\t},\n\t\t\tgetConnections() {\n\t\t\t\treturn [];\n\t\t\t},\n\t\t};\n\n\t\tconst connectionsMap = new Map<string, Map<number, ConnectionTarget[]>>();\n\t\tlet mapKey = nodeName || `__unnamed_${unnamedCounter++}`;\n\n\t\t// Handle duplicate node names: generate unique key for duplicates\n\t\t// The first instance keeps the original name (connections reference it)\n\t\tif (nodes.has(mapKey)) {\n\t\t\tmapKey = generateUniqueName(nodeName, (n) => nodes.has(n));\n\t\t} else {\n\t\t\tnameToKey.set(nodeName, mapKey);","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder/workflow-import.ts#L82-L118","documentation":"Imported (fromJSON) node handles do not implement output(). output() returns an OutputSelector on authored nodes so a specific output index of a branching node (IF, Switch) can be wired; imported nodes already encode all output connections in JSON, so the selector is unavailable. The throw is intentional to stop callers from producing half-wired selectors that connect nothing.","triggerScenarios":"Calling node.output(0) on a node handle obtained via fromJSON(), then chaining .to(target) or passing the selector to workflow.add().","commonSituations":"Porting builder code that branched on IF/Switch outputs to an imported workflow; generic graph-walking utilities that assume all nodes support output().","solutions":["Re-author the branching node with the builder factories if you need output selection.","Use workflow.connect(source, outputIndex, target, 0) to wire a specific output index.","Edit the JSON connections map directly before importing."],"exampleFix":"// before\nconst n = wf.getNode('If'); // imported\nn.output(0).to(a); // throws\n\n// after\nwf.connect(n, 0, a, 0);","handlingStrategy":"type-guard","validationCode":"function isImportedNode(n: any): boolean {\n  return n.__imported === true;\n}\nif (isImportedNode(n)) {\n  throw new Error('Cannot call output() on imported node; use wf.connect()');\n}","typeGuard":"function isImportedNode(n: { __imported?: boolean }): boolean {\n  return n.__imported === true;\n}","tryCatchPattern":"try {\n  n.output(0).to(target);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('fromJSON()')) {\n    wf.connect(n, 0, target, 0);\n  } else throw e;\n}","preventionTips":["Use workflow.connect(source, outputIndex, target, targetInput) for imported node output wiring.","Re-author branching nodes via builder factories when output selection is needed.","Edit the JSON connections map before import to encode output-index wiring."],"tags":["workflow-builder","fromjson","import","connections"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}