n8n-io/n8n · warning
SDK_FORBIDDEN_CONSTRUCT
SDK_FORBIDDEN_CONSTRUCT
Error message
Arrow functions are not allowed. Use fromAi() directly instead of ($) => $.fromAi()
What it means
SDK_FORBIDDEN_CONSTRUCT for ArrowFunctionExpression is a lint issue. The FORBIDDEN_NODE_TYPES map assigns arrow functions the message 'Use fromAi() directly instead of ($) => $.fromAi()'. The SDK builder interpreter rejects arrow functions entirely; fromAi() must be called directly as a parameter value.
Source
Thrown at packages/@n8n/workflow-sdk/src/lint/sdk/workflow-sdk-lint.ts:217
...locationOf(stmt),
lintTarget: 'sdk',
}),
);
}
}
const branchCounts = new Map<string, { count: number; line?: number; column?: number }>();
walkAst(
ast,
(node, parent) => {
if (node.type === 'ImportDeclaration') return;
const forbidden = FORBIDDEN_NODE_TYPES[node.type];
if (forbidden) {
issues.push(
lintIssue({
code: 'SDK_FORBIDDEN_CONSTRUCT',
message: forbidden,
...locationOf(node),
lintTarget: 'sdk',
}),
);
}
if (node.type === 'Identifier' && DANGEROUS_GLOBALS.has(node.name)) {
const isPropertyName =
parent?.type === 'MemberExpression' && parent.property === node && !parent.computed;
const isObjectKey = parent?.type === 'Property' && parent.key === node;
// Mirrors the interpreter: safe global methods (e.g. JSON.stringify) are allowed.
const isSafeMethodObject =
parent?.type === 'MemberExpression' &&
parent.object === node &&
!parent.computed &&
parent.property.type === 'Identifier' &&
getSafeJSONMethod(node.name, parent.property.name) !== undefined;View on GitHub (pinned to 5ac6606e81)
Solutions
- Use fromAi() directly as the parameter value, e.g. fromAi: fromAi('x').
- Replace array callbacks with declarative builder calls or move the logic to a Code node.
- Inline any lambda logic so the SDK source has no arrow expressions.
Example fix
// before
export default workflow().addNode(httpRequest({
parameters: { prompt: ($) => $.fromAi('prompt') },
}));
// after
export default workflow().addNode(httpRequest({
parameters: { prompt: fromAi('prompt') },
})); 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_FORBIDDEN_CONSTRUCT' && i.message.includes('Arrow functions'))) {
throw new Error('Arrow functions are forbidden in SDK code; call fromAi() directly.');
} Prevention
- Use fromAi() directly as the parameter value, never ($) => $.fromAi().
- Avoid array callbacks (.map(x => ...)) in SDK source — move transforms to a Code node.
- Lint generated SDK code to catch arrow functions.
When it happens
Trigger: fromAi: ($) => $.fromAi('x'), callbacks like .map((x) => x), or any () => ... / (x) => ... expression in SDK builder code.
Common situations: Agent wraps fromAi in an arrow callback; developer uses functional array methods; LLM emits a lambda for a helper.
Related errors
- SDK_CODE_AFTER_EXPORT_DEFAULT
- SDK_REPEATED_BRANCH_WIRING
- VectorStore "${this.name}" requires an embedding model — set
- CODE_NODE_NETWORK_CALL
- CODE_NODE_FORBIDDEN_IMPORT
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b73f6e5259defe87.
Report an issue: GitHub.