n8n-io/n8n · warning
SDK_AS_CONST
SDK_AS_CONST
Error message
`as const` is TypeScript-only and the workflow parser cannot interpret it. Remove the assertion.
What it means
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.
Source
Thrown at packages/@n8n/workflow-sdk/src/lint/lint-workflow-source.ts:24
import { lintWorkflowSdkAst, prepareSourceForLint } from './sdk/workflow-sdk-lint';
import { lintIssue, type SourceLintIssue } from './types';
/**
* Run SDK, embedded JavaScript, and embedded Python linters on a workflow source file.
* Parses the prepared source once and shares the AST across passes.
*/
export function lintWorkflowSource(source: string): SourceLintIssue[] {
const { code, asConstMatches } = prepareSourceForLint(source);
let ast;
try {
ast = parseSDKCode(code);
} catch {
// Still surface `as const` findings when the file does not parse.
return dedupeSourceLintIssues(
asConstMatches.map((match) =>
lintIssue({
code: 'SDK_AS_CONST',
message:
'`as const` is TypeScript-only and the workflow parser cannot interpret it. Remove the assertion.',
line: match.line,
column: match.column + 1,
lintTarget: 'sdk' as const,
}),
),
);
}
const sdkIssues = lintWorkflowSdkAst(ast, asConstMatches);
const parents = buildParentMap(ast);
const snippets = extractEmbeddedCodeSnippets(ast, code, parents);
const embeddedIssues: SourceLintIssue[] = [];
for (const snippet of snippets) {
const base = { line: snippet.line, column: snippet.column };
if (snippet.parameter === 'jsCode') {View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before
export default {
type: 'n8n-nodes-base.scheduleTrigger'
as const,
} // (also missing comma -> parse error)
// after
export default workflow()
.addNode(scheduleTrigger()); Defensive patterns
Strategy: validation
Validate before calling
import { lintWorkflowSource } from '@n8n/workflow-sdk/lint/lint-workflow-source';
const issues = lintWorkflowSource(sdkSource);
if (issues.some((i) => i.code === 'SDK_AS_CONST')) {
throw new Error('SDK source contains `as const`; remove it and fix any parse errors.');
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- SDK_AS_CONST
- CODE_NODE_NETWORK_CALL
- CODE_NODE_FORBIDDEN_IMPORT
- CODE_MODE_API_MISUSE
- CODE_NESTED_TEMPLATE_LITERAL
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/97da090515c887af.
Report an issue: GitHub.