n8n-io/n8n · error · InterpreterError
Syntax error: ${error.message}
Error message
Syntax error: ${error.message} What it means
Thrown by parseSDKCode (Acorn wrapper) when the input code fails to parse as valid JavaScript/ECMAScript. Acorn raises a SyntaxError; the wrapper extracts the location (line/column) from `error.loc` and re-throws as InterpreterError with a code frame. This is the top-level parse gate before any AST interpretation.
Source
Thrown at packages/@n8n/workflow-sdk/src/ast-interpreter/parser.ts:39
try {
// Acorn's AST is compatible with ESTree, but TypeScript doesn't know that
return acorn.parse(code, {
ecmaVersion: 'latest',
sourceType: 'module',
locations: true, // Include line/column info for error messages
}) as unknown as Program;
} catch (error) {
if (error instanceof SyntaxError) {
// Extract location from Acorn's error message
const match = (error as { loc?: { line: number; column: number } }).loc;
const location = match
? {
start: { line: match.line, column: match.column },
end: { line: match.line, column: match.column + 1 },
}
: undefined;
throw new InterpreterError(`Syntax error: ${error.message}`, location, code);
}
throw error;
}
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Read the line/column in the error's code frame and fix the syntax at that exact location.
- Paste the code into a JS/TS-aware editor (VS Code, ESLint) to locate the syntax error before submitting.
- If the code was generated, regenerate it — do not hand-edit large generated blocks; if hand-editing, validate with a linter.
- Check for unclosed template literals (backticks) and unbalanced brackets first — these are the most common cause flagged by the SDK error hint.
Example fix
// before
export default workflow()
.add(node('X').parameters({ a: 1 )});
// after
export default workflow()
.add(node('X').parameters({ a: 1 })); Defensive patterns
Strategy: try-catch
Validate before calling
// Validate syntax with a plain JS parser before feeding the SDK interpreter
import * as acorn from 'acorn';
function checkSyntax(code: string): { ok: true } | { ok: false; message: string; line?: number } {
try {
acorn.parse(code, { ecmaVersion: 'latest', sourceType: 'module', locations: true });
return { ok: true };
} catch (e) {
const err = e as { message: string; loc?: { line: number } };
return { ok: false, message: err.message, line: err.loc?.line };
}
} Type guard
function isParsableModule(code: string): boolean {
try {
acorn.parse(code, { ecmaVersion: 'latest', sourceType: 'module' });
return true;
} catch {
return false;
}
} Try / catch
import { parseSDKCode } from '@n8n/workflow-sdk/ast-interpreter/parser';
import { InterpreterError } from '@n8n/workflow-sdk/ast-interpreter/errors';
try {
parseSDKCode(code);
} catch (e) {
if (e instanceof InterpreterError && /Syntax error/.test(e.message)) {
// show the code frame + message to the user; the error carries line/column
}
throw e;
} Prevention
- Always validate SDK code with acorn (or a JS-aware editor) before submitting it to the interpreter.
- Bracket-balance: count '{', '}', '(', ')', '[', ']', '`' before submit.
- Never hand-edit large generated code blocks; regenerate instead.
When it happens
Trigger: Unclosed template literals, missing commas, unbalanced brackets/braces/parens, invalid token sequences, unterminated strings, stray characters. Any input string that is not syntactically valid ES (parsed with ecmaVersion 'latest', sourceType 'module').
Common situations: Hand-editing generated SDK code and leaving a syntax error; JSON.stringify double-escaping producing malformed code; copy-paste introducing smart quotes or missing closing braces; template literal `${}` with unbalanced backticks.
Related errors
- VectorStore "${this.name}" requires an embedding model — set
- topK must be an integer >= 1, got ${k}
- Cannot assign property on ${String(obj)}
- Unsupported syntax: 'Dynamic property assignment' is not all
- Unsupported syntax: '${node.type}: ${FORBIDDEN_NODE_TYPES[no
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/823e4f652cf80069.
Report an issue: GitHub.