n8n-io/n8n · error · NodeOperationError

No code for "Execute" set on node "${this.getNode().name}

Error message

No code for "Execute" set on node "${this.getNode().name}

What it means

Thrown by the Code node (langchain variant) when the 'code' parameter's execute.code is missing or empty. The node runs a user-supplied JavaScript 'execute' function in a sandbox; if that function's source is blank, there is nothing to run.

Source

Thrown at packages/@n8n/nodes-langchain/nodes/code/Code.node.ts:419

								noDataExpression: true,
								default: '',
								required: true,
								description: 'The type of the input',
							},
						],
					},
				],
			},
		],
	};

	async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
		const itemIndex = 0;

		const code = this.getNodeParameter('code', itemIndex) as { execute?: { code: string } };

		if (!code.execute?.code) {
			throw new NodeOperationError(
				this.getNode(),
				`No code for "Execute" set on node "${this.getNode().name}`,
				{
					itemIndex,
				},
			);
		}

		const sandbox = getSandbox.call(this, code.execute.code, { addItems: true, itemIndex });

		const outputs = this.getNodeOutputs();
		const mainOutputs: INodeOutputConfiguration[] = outputs.filter(
			(output) => output.type === NodeConnectionTypes.Main,
		);

		const options = { multiOutput: mainOutputs.length !== 1 };

		let items: INodeExecutionData[] | INodeExecutionData[][];

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Open the Code node and write a valid execute function, e.g. `async function execute(items) { for (const item of items) { item.json.result = 1; } return items; }`.
  2. If importing a workflow, ensure the code field was included in the import payload.
  3. Select a Code node template from the node's templates panel to get a valid starting point.

Example fix

// before
if (!code.execute?.code) {
  throw new NodeOperationError(this.getNode(), `No code for "Execute" set on node "${this.getNode().name}`, { itemIndex });
}

// after — clearer instruction with a minimal example
if (!code.execute?.code?.trim()) {
  throw new NodeOperationError(this.getNode(), {
    message: `No code for "Execute" set on node "${this.getNode().name}".`,
    description: 'Add a function like: async function execute(items) { return items; }',
    itemIndex,
  });
}
Defensive patterns

Strategy: validation

Validate before calling

const code = ctx.getNodeParameter('code', 0) as { execute?: { code?: string } };
if (!code.execute?.code?.trim()) {
  throw new Error('Code node has no execute function. Add: async function execute(items) { return items; }');
}

Type guard

function hasExecuteCode(c: unknown): c is { execute: { code: string } } {
  return !!c && typeof (c as any)?.execute?.code === 'string' && (c as any).execute.code.trim().length > 0;
}

Prevention

When it happens

Trigger: The Code node's 'JavaScript' (execute) code editor is empty, or the code parameter object exists but its .execute.code property is falsy. The guard throws before sandbox construction.

Common situations: User added a Code node but never wrote the execute function; the code was cleared by a bad import; the node was duplicated from a template that had empty code; a programmatic workflow generator emitted a code node without code.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/2e2fbb5a8c5dfd2b. Report an issue: GitHub.