{"record":{"id":"e4f0652c7aea391a","repo":"n8n-io/n8n","slug":"expected-a-json-array-of-objects-got-a-single-val","errorCode":null,"errorMessage":"Expected a JSON array of objects, got a single value or object","messagePattern":"Expected a JSON array of objects, got a single value or object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts","lineNumber":325,"sourceCode":"\t\t}\n\t}\n\n\treturn { rawHeaders, allRows: dataRows };\n}\n\nfunction parseJson(content: string): {\n\trawHeaders: string[];\n\tallRows: Array<Record<string, unknown>>;\n} {\n\tlet parsed: unknown;\n\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);","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts#L307-L343","documentation":"Error \"Expected a JSON array of objects, got a single value or object\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts:325 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"}