{"record":{"id":"a3b75895c5fe8a19","repo":"n8n-io/n8n","slug":"sdk-code-after-export-default","errorCode":"SDK_CODE_AFTER_EXPORT_DEFAULT","errorMessage":"Statement after `export default workflow(...)` never reaches the builder — nodes/wiring here are dropped. Compose all `.to()` / `.onTrue()` / `.onFalse()` / `.onCase()` inside the export default chain.","messagePattern":"Statement after `export default workflow\\(\\.\\.\\.\\)` never reaches the builder — nodes/wiring here are dropped\\. Compose all `\\.to\\(\\)` / `\\.onTrue\\(\\)` / `\\.onFalse\\(\\)` / `\\.onCase\\(\\)` inside the export default chain\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/@n8n/workflow-sdk/src/lint/sdk/workflow-sdk-lint.ts","lineNumber":195,"sourceCode":"\t\t\tlintIssue({\n\t\t\t\tcode: 'SDK_AS_CONST',\n\t\t\t\tmessage:\n\t\t\t\t\t'`as const` is TypeScript-only and the workflow parser cannot interpret it. Remove the assertion.',\n\t\t\t\tline: match.line,\n\t\t\t\tcolumn: match.column + 1,\n\t\t\t\tlintTarget: 'sdk',\n\t\t\t}),\n\t\t);\n\t}\n\n\tconst exportIndex = ast.body.findIndex((stmt) => stmt.type === 'ExportDefaultDeclaration');\n\tif (exportIndex >= 0) {\n\t\tfor (let i = exportIndex + 1; i < ast.body.length; i++) {\n\t\t\tconst stmt = ast.body[i];\n\t\t\tif (!stmt || stmt.type === 'EmptyStatement') continue;\n\t\t\tissues.push(\n\t\t\t\tlintIssue({\n\t\t\t\t\tcode: 'SDK_CODE_AFTER_EXPORT_DEFAULT',\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'Statement after `export default workflow(...)` never reaches the builder — nodes/wiring here are dropped. ' +\n\t\t\t\t\t\t'Compose all `.to()` / `.onTrue()` / `.onFalse()` / `.onCase()` inside the export default chain.',\n\t\t\t\t\t...locationOf(stmt),\n\t\t\t\t\tlintTarget: 'sdk',\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tconst branchCounts = new Map<string, { count: number; line?: number; column?: number }>();\n\n\twalkAst(\n\t\tast,\n\t\t(node, parent) => {\n\t\t\tif (node.type === 'ImportDeclaration') return;\n\n\t\t\tconst forbidden = FORBIDDEN_NODE_TYPES[node.type];","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/lint/sdk/workflow-sdk-lint.ts#L177-L213","documentation":"SDK_CODE_AFTER_EXPORT_DEFAULT is a lint issue. lintWorkflowSdkAst() finds the ExportDefaultDeclaration index and flags every non-EmptyStatement after it, because any node construction or wiring (.to()/.onTrue()/etc.) written as a separate top-level statement after export default is dropped — the builder only consumes the export default chain.","triggerScenarios":"export default workflow().to(a); a.to(b); — or any node construction, assignment, or wiring call appearing as a top-level statement after the export default line.","commonSituations":"Agent adds wiring as separate statements instead of chaining; developer appends nodes 'after' the export; refactor leaves orphan statements.","solutions":["Move all .to()/.onTrue()/.onFalse()/.onCase()/.onDone() calls inside the single export default chain.","Delete any stray top-level statements after export default.","Restructure so the entire workflow is one fluent expression terminating at export default."],"exampleFix":"// before\nexport default workflow().to(a);\na.to(b);\nb.onTrue(c);\n// after\nexport default workflow().to(a).to(b).onTrue(c);","handlingStrategy":"validation","validationCode":"import { lintWorkflowSource } from '@n8n/workflow-sdk/lint/lint-workflow-source';\nconst issues = lintWorkflowSource(sdkSource);\nif (issues.some((i) => i.code === 'SDK_CODE_AFTER_EXPORT_DEFAULT')) {\n  throw new Error('Statements after export default are dropped; fold all wiring into the export default chain.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Make the entire workflow a single fluent chain ending at export default.","Never add .to()/.onTrue()/.onFalse()/.onCase() as separate top-level statements.","Run lintWorkflowSource on generated SDK code before deploy."],"tags":["lint","sdk","builder"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}