n8n-io/n8n · error

ARRAY_INPUT_COLLAPSED_TO_FIRST_ITEM

ARRAY_INPUT_COLLAPSED_TO_FIRST_ITEM

Error message

Code node reads the first input item (e.g. $input.first().json / items[0].json) and applies an array operation to it, but its upstream HTTP Request node "${httpParent}" splits a top-level array into one item per element. The first item is a single element, not the whole array, so the rest are dropped. Read every item with $input.all().map(i => i.json) (or iterate the items) instead.

What it means

Error "Code node reads the first input item (e.g. $input.first().json / items[0].json) and applies an array operation to it, but its upstream HTTP Request node "${httpParent}" splits a top-level array into one item per element. The first item is a single element, not the whole array, so the rest are dropped. Read every item with $input.all().map(i => i.json) (or iterate the items) instead." thrown in n8n-io/n8n.

Source

Thrown at packages/@n8n/instance-ai/src/tools/workflows/detect-array-input-collapse.ts:95

 */
export function detectArrayInputCollapse(json: WorkflowJSON): ValidationWarning[] {
	const warnings: ValidationWarning[] = [];
	const typeByName = nodeTypeByName(json);

	for (const node of json.nodes ?? []) {
		if (node.type !== CODE_NODE_TYPE) continue;
		const params = node.parameters;
		const jsCode = isRecord(params) && typeof params.jsCode === 'string' ? params.jsCode : '';
		if (!jsCode || !treatsJsonAsArray(jsCode)) continue;

		const httpParent =
			typeof node.name === 'string'
				? mainInputSources(json, node.name).find((s) => typeByName.get(s)?.includes('httpRequest'))
				: undefined;
		if (!httpParent) continue;

		warnings.push({
			code: 'ARRAY_INPUT_COLLAPSED_TO_FIRST_ITEM',
			nodeName: typeof node.name === 'string' ? node.name : undefined,
			message:
				'Code node reads the first input item (e.g. $input.first().json / items[0].json) and applies an array ' +
				`operation to it, but its upstream HTTP Request node "${httpParent}" splits a top-level array into one ` +
				'item per element. The first item is a single element, not the whole array, so the rest are dropped. ' +
				'Read every item with $input.all().map(i => i.json) (or iterate the items) instead.',
		});
	}

	return warnings;
}

View on GitHub (pinned to 5ac6606e81)

When it happens

Trigger: Thrown at packages/@n8n/instance-ai/src/tools/workflows/detect-array-input-collapse.ts:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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