n8n-io/n8n · error · NodeOperationError

No code for "Supply Data" set on node "${this.getNode().name

Error message

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

What it means

Thrown by the Code node's supplyData() method when the node is configured in 'Supply Data' mode but the user has not entered any JavaScript code in the supplyData.code parameter. The node reads the 'code' parameter expecting an object with a supplyData.code string; if that string is absent or empty, it cannot build a sandbox or run anything, so execution halts with a NodeOperationError tagged with the offending itemIndex.

Source

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

			for (const item of items as INodeExecutionData[]) {
				standardizeOutput(item.json);
			}
			return [items as INodeExecutionData[]];
		} else {
			items.forEach((data) => {
				for (const item of data as INodeExecutionData[]) {
					standardizeOutput(item.json);
				}
			});
			return items as INodeExecutionData[][];
		}
	}

	async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
		const code = this.getNodeParameter('code', itemIndex) as { supplyData?: { code: string } };

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

		const sandbox = getSandbox.call(this, code.supplyData.code, { itemIndex });
		const response = await sandbox.runCode<Tool>();

		return {
			response: logWrapper(response, this),
		};
	}
}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Open the Code node, confirm the mode selector is on 'Supply Data', and write valid JavaScript in the code editor (e.g. return $input.all();).
  2. If importing a workflow, verify the JSON's parameters.code.supplyData.code is a non-empty string before activating.
  3. Pin the node typeVersion and re-open in the latest n8n UI so the parameter path 'code.supplyData.code' matches what supplyData() reads.

Example fix

// before
this.getNodeParameter('code', itemIndex) === { supplyData: { code: '' } }
// after
this.getNodeParameter('code', itemIndex) === { supplyData: { code: 'return $input.all();' } }
Defensive patterns

Strategy: validation

Validate before calling

// Before calling supplyData, ensure the parameter is non-empty
const codeParam = this.getNodeParameter('code', itemIndex) as { supplyData?: { code?: string } };
if (!codeParam?.supplyData?.code?.trim()) {
  // surface a UI-level warning or skip the node rather than throwing at runtime
  throw new Error('Open the Code node and author the Supply Data function before executing.');
}

Type guard

const hasSupplyDataCode = (
  p: unknown,
): p is { supplyData: { code: string } } =>
  typeof p === 'object' && p !== null &&
  'supplyData' in p &&
  typeof (p as any).supplyData?.code === 'string' &&
  (p as any).supplyData.code.trim().length > 0;

Try / catch

// Not applicable — pre-validate the parameter; runtime catch only re-surfaces the NodeOperationError.

Prevention

When it happens

Trigger: The Code node parameter 'code' resolves to an object whose supplyData.code property is undefined, null, or empty string. This happens when the node's mode is set to 'Run Once for Each Item' / 'Run Once for All Items' alternate 'Supply Data' but the code editor was left blank or the parameter JSON was hand-edited to omit the code field.

Common situations: Switching a Code node into 'Supply Data' mode in an AI workflow (LangChain tool/passthrough) and forgetting to author the supplyData function; importing a workflow JSON where the code field was stripped; UI bug or stale draft where the editor shows content but the saved parameter is empty.

Related errors


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