{"record":{"id":"97da090515c887af","repo":"n8n-io/n8n","slug":"sdk-as-const","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/lint-workflow-source.ts","lineNumber":24,"sourceCode":"import { lintWorkflowSdkAst, prepareSourceForLint } from './sdk/workflow-sdk-lint';\nimport { lintIssue, type SourceLintIssue } from './types';\n\n/**\n * Run SDK, embedded JavaScript, and embedded Python linters on a workflow source file.\n * Parses the prepared source once and shares the AST across passes.\n */\nexport function lintWorkflowSource(source: string): SourceLintIssue[] {\n\tconst { code, asConstMatches } = prepareSourceForLint(source);\n\n\tlet ast;\n\ttry {\n\t\tast = parseSDKCode(code);\n\t} catch {\n\t\t// Still surface `as const` findings when the file does not parse.\n\t\treturn dedupeSourceLintIssues(\n\t\t\tasConstMatches.map((match) =>\n\t\t\t\tlintIssue({\n\t\t\t\t\tcode: 'SDK_AS_CONST',\n\t\t\t\t\tmessage:\n\t\t\t\t\t\t'`as const` is TypeScript-only and the workflow parser cannot interpret it. Remove the assertion.',\n\t\t\t\t\tline: match.line,\n\t\t\t\t\tcolumn: match.column + 1,\n\t\t\t\t\tlintTarget: 'sdk' as const,\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t}\n\n\tconst sdkIssues = lintWorkflowSdkAst(ast, asConstMatches);\n\tconst parents = buildParentMap(ast);\n\tconst snippets = extractEmbeddedCodeSnippets(ast, code, parents);\n\n\tconst embeddedIssues: SourceLintIssue[] = [];\n\tfor (const snippet of snippets) {\n\t\tconst base = { line: snippet.line, column: snippet.column };\n\t\tif (snippet.parameter === 'jsCode') {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/lint/lint-workflow-source.ts#L6-L42","documentation":"SDK_AS_CONST emitted from lintWorkflowSource() is a lint issue. prepareSourceForLint() collects every 'as const' occurrence before stripping; if the source then fails to parse (other syntax errors), the linter still returns these matches as SDK_AS_CONST issues so the assertion is reported even when the file does not parse.","triggerScenarios":"An SDK source file that contains 'as const' AND a separate syntax error that prevents acorn from parsing the prepared code (the catch branch in lintWorkflowSource).","commonSituations":"Agent output mixing TS-only assertions with other unparseable syntax; partial/garbled SDK source; TS literal narrowing left in by mistake alongside a real parse error.","solutions":["Remove all `as const` assertions from the SDK source — the workflow parser cannot interpret them.","Fix the other syntax error(s) so the file parses; once it parses, the full SDK lint runs and other issues surface clearly.","Use plain object literals or the SDK factory helpers instead of `as const` narrowing."],"exampleFix":"// before\nexport default {\n  type: 'n8n-nodes-base.scheduleTrigger'\n  as const,\n}  // (also missing comma -> parse error)\n// after\nexport default workflow()\n  .addNode(scheduleTrigger());","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 contains `as const`; remove it and fix any parse errors.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use `as const` in SDK builder source — the parser ignores TS assertions.","Keep SDK source parseable so the full lint pass runs (other issues surface only after parse).","Use the SDK factory helpers instead of TS literal narrowing."],"tags":["lint","sdk","typescript"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}