n8n-io/n8n · error

Expected a JSON array of objects, got a single value or obje

Error message

Expected a JSON array of objects, got a single value or object

What it means

Error "Expected a JSON array of objects, got a single value or object" thrown in n8n-io/n8n.

Source

Thrown at packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts:325

		}
	}

	return { rawHeaders, allRows: dataRows };
}

function parseJson(content: string): {
	rawHeaders: string[];
	allRows: Array<Record<string, unknown>>;
} {
	let parsed: unknown;
	try {
		parsed = JSON.parse(content);
	} catch {
		throw new Error('Invalid JSON: failed to parse');
	}

	if (!Array.isArray(parsed)) {
		throw new Error('Expected a JSON array of objects, got a single value or object');
	}

	if (parsed.length === 0) {
		return { rawHeaders: [], allRows: [] };
	}

	// Collect all keys across all objects (preserving order of first appearance)
	const keySet = new Set<string>();
	for (const item of parsed) {
		if (typeof item !== 'object' || item === null || Array.isArray(item)) {
			throw new Error('JSON array items must be flat objects (not arrays, nulls, or primitives)');
		}
		const dangerousKey = hasDangerousKey(item as Record<string, unknown>);
		if (dangerousKey) {
			throw new Error(`Dangerous key "${dangerousKey}" found in JSON data`);
		}
		for (const key of Object.keys(item as Record<string, unknown>)) {
			keySet.add(key);

View on GitHub (pinned to 5ac6606e81)

When it happens

Trigger: Thrown at packages/@n8n/instance-ai/src/parsers/structured-file-parser.ts:325 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/e4f0652c7aea391a. Report an issue: GitHub.