{"record":{"id":"c0625e34b5c9b75b","repo":"n8n-io/n8n","slug":"array-input-collapsed-to-first-item","errorCode":"ARRAY_INPUT_COLLAPSED_TO_FIRST_ITEM","errorMessage":"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.","messagePattern":"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 \"(.+?)\" 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\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/workflows/detect-array-input-collapse.ts","lineNumber":95,"sourceCode":" */\nexport function detectArrayInputCollapse(json: WorkflowJSON): ValidationWarning[] {\n\tconst warnings: ValidationWarning[] = [];\n\tconst typeByName = nodeTypeByName(json);\n\n\tfor (const node of json.nodes ?? []) {\n\t\tif (node.type !== CODE_NODE_TYPE) continue;\n\t\tconst params = node.parameters;\n\t\tconst jsCode = isRecord(params) && typeof params.jsCode === 'string' ? params.jsCode : '';\n\t\tif (!jsCode || !treatsJsonAsArray(jsCode)) continue;\n\n\t\tconst httpParent =\n\t\t\ttypeof node.name === 'string'\n\t\t\t\t? mainInputSources(json, node.name).find((s) => typeByName.get(s)?.includes('httpRequest'))\n\t\t\t\t: undefined;\n\t\tif (!httpParent) continue;\n\n\t\twarnings.push({\n\t\t\tcode: 'ARRAY_INPUT_COLLAPSED_TO_FIRST_ITEM',\n\t\t\tnodeName: typeof node.name === 'string' ? node.name : undefined,\n\t\t\tmessage:\n\t\t\t\t'Code node reads the first input item (e.g. $input.first().json / items[0].json) and applies an array ' +\n\t\t\t\t`operation to it, but its upstream HTTP Request node \"${httpParent}\" splits a top-level array into one ` +\n\t\t\t\t'item per element. The first item is a single element, not the whole array, so the rest are dropped. ' +\n\t\t\t\t'Read every item with $input.all().map(i => i.json) (or iterate the items) instead.',\n\t\t});\n\t}\n\n\treturn warnings;\n}\n","sourceCodeStart":77,"sourceCodeEnd":107,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/workflows/detect-array-input-collapse.ts#L77-L107","documentation":"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.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/workflows/detect-array-input-collapse.ts:95 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}