{"record":{"id":"eb8240a9b07f0be6","repo":"n8n-io/n8n","slug":"json-array-items-must-be-flat-objects-not-arrays","errorCode":null,"errorMessage":"JSON array items must be flat objects (not arrays, nulls, or primitives)","messagePattern":"JSON array items must be flat objects \\(not arrays, nulls, or primitives\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts","lineNumber":336,"sourceCode":"\ttry {\n\t\tparsed = JSON.parse(content);\n\t} catch {\n\t\tthrow new Error('Invalid JSON: failed to parse');\n\t}\n\n\tif (!Array.isArray(parsed)) {\n\t\tthrow new Error('Expected a JSON array of objects, got a single value or object');\n\t}\n\n\tif (parsed.length === 0) {\n\t\treturn { rawHeaders: [], allRows: [] };\n\t}\n\n\t// Collect all keys across all objects (preserving order of first appearance)\n\tconst keySet = new Set<string>();\n\tfor (const item of parsed) {\n\t\tif (typeof item !== 'object' || item === null || Array.isArray(item)) {\n\t\t\tthrow new Error('JSON array items must be flat objects (not arrays, nulls, or primitives)');\n\t\t}\n\t\tconst dangerousKey = hasDangerousKey(item as Record<string, unknown>);\n\t\tif (dangerousKey) {\n\t\t\tthrow new Error(`Dangerous key \"${dangerousKey}\" found in JSON data`);\n\t\t}\n\t\tfor (const key of Object.keys(item as Record<string, unknown>)) {\n\t\t\tkeySet.add(key);\n\t\t}\n\t}\n\n\tconst rawHeaders = [...keySet];\n\n\t// Validate all values are flat\n\tfor (const item of parsed) {\n\t\tconst obj = item as Record<string, unknown>;\n\t\tfor (const [key, value] of Object.entries(obj)) {\n\t\t\tif (value !== null && typeof value === 'object') {\n\t\t\t\tthrow new Error(","sourceCodeStart":318,"sourceCodeEnd":354,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts#L318-L354","documentation":"Error \"JSON array items must be flat objects (not arrays, nulls, or primitives)\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts:336 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"}