{"record":{"id":"d3754756f27d49d4","repo":"n8n-io/n8n","slug":"sdk-as-const-d37547","errorCode":"SDK_AS_CONST","errorMessage":"`as const` is TypeScript-only and the workflow parser cannot interpret it. Remove the assertion.","messagePattern":"`as const` is TypeScript-only and the workflow parser cannot interpret it\\. Remove the assertion\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/@n8n/workflow-sdk/src/lint/sdk/workflow-sdk-lint.ts","lineNumber":178,"sourceCode":"\tif (line < range.startLine || line > range.endLine) return false;\n\tif (line === range.startLine && column < range.startColumn) return false;\n\tif (line === range.endLine && column >= range.endColumn) return false;\n\treturn true;\n}\n\n/** Lint a prepared, parsed SDK AST (imports/TS already stripped). */\nexport function lintWorkflowSdkAst(\n\tast: Program,\n\tasConstMatches: AsConstMatch[] = [],\n): SourceLintIssue[] {\n\tconst issues: SourceLintIssue[] = [];\n\n\tconst stringRanges = stringContentRanges(ast);\n\tfor (const match of asConstMatches) {\n\t\tif (stringRanges.some((range) => rangeContains(range, match.line, match.column))) continue;\n\t\tissues.push(\n\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:","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/lint/sdk/workflow-sdk-lint.ts#L160-L196","documentation":"SDK_AS_CONST emitted from lintWorkflowSdkAst() is a lint issue. After a successful parse, each collected 'as const' match that is NOT inside a string/template literal range is flagged, because the workflow parser cannot interpret TS assertions. String-content matches (e.g. inside jsCode) are intentionally skipped via stringContentRanges().","triggerScenarios":"mode: 'runOnceForAllItems' as const, type: 'webhook' as const, or any `as const` assertion on a literal in SDK builder code outside of a string.","commonSituations":"Agent writes idiomatic TS literal narrowing; developer copies typed config from a TS file; assertion left over from a type-driven design.","solutions":["Delete the `as const` assertion — the literal value itself is enough.","If you need a typed literal, keep it in a separate non-SDK TS module; the SDK source must stay assertion-free.","Re-run lintWorkflowSource to confirm zero SDK_AS_CONST issues."],"exampleFix":"// before\nexport default workflow()\n  .addNode(httpRequest({\n    parameters: { method: 'POST' as const },\n  }));\n// after\nexport default workflow()\n  .addNode(httpRequest({\n    parameters: { method: 'POST' },\n  }));","handlingStrategy":"validation","validationCode":"import { lintWorkflowSource } from '@n8n/workflow-sdk/lint/lint-workflow-source';\nconst issues = lintWorkflowSource(sdkSource);\nif (issues.some((i) => i.code === 'SDK_AS_CONST')) {\n  throw new Error('SDK source has `as const` outside strings; remove the assertion.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Delete `as const` from SDK source; the bare literal is sufficient.","Keep typed helpers in a separate non-SDK module.","Lint generated SDK code in CI."],"tags":["lint","sdk","typescript"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}