Kong/insomnia · error
Invalid JSON file uploaded, JSON file must be array of…
Error message
Invalid JSON file uploaded, JSON file must be array of key-value pairs.
What it means
Thrown by getListFromFileOrUrl when parsing an iteration-data JSON file whose top-level value parses successfully but is not an array. The CLI requires iteration data files to be a JSON array of key-value-pair objects; any other JSON shape (object, string, number) triggers this guard before transformation into environment entries.
Solutions
- Reformat the JSON file as an array of objects, e.g. [{"user":"a"},{"user":"b"}]
- Ensure each array element is a plain object of string keys/values, not scalars or nested arrays
- Use CSV format instead if the data is tabular
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/insomnia-inso/src/cli.ts:227 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of Kong/insomnia@d9bb2b0142 (2026-08-26).
Data as JSON: /api/errors/0ba840932e5bf5cd.
Report an issue: GitHub.
Appendix: source
Thrown at packages/insomnia-inso/src/cli.ts:227
.reduce((acc, obj) => ({ ...acc, ...obj }), {});
const fileType = pathOrUrl.split('.').pop()?.toLowerCase();
const content = await readFileFromPathOrUrl(pathOrUrl);
if (!content) {
return transformIterationDataToEnvironmentList([envAsObject]);
}
const list = getListFromFileOrUrl(content, fileType).map(data => ({ ...data, ...envAsObject }));
return transformIterationDataToEnvironmentList(list);
};
const getListFromFileOrUrl = (content: string, fileType?: string): Record<string, string>[] => {
if (fileType === 'json') {
try {
const jsonDataContent = JSON.parse(content);
if (Array.isArray(jsonDataContent)) {
return jsonDataContent.filter(
data => data && typeof data === 'object' && !Array.isArray(data) && data !== null,
);
}
throw new Error('Invalid JSON file uploaded, JSON file must be array of key-value pairs.');
} catch {
throw new Error('Upload JSON file can not be parsed');
}
} else if (fileType === 'csv') {
// Replace CRLF (Windows line break) and CR (Mac link break) with \n, then split into csv arrays
const csvRows = content
.replace(/\r\n|\r/g, '\n')
.split('\n')
.map(row => row.split(','));
// at least 2 rows required for csv
if (csvRows.length > 1) {
const csvHeaders = csvRows[0];
const csvContentRows = csvRows.slice(1);
return csvContentRows.map(contentRow =>
csvHeaders.reduce((acc: Record<string, any>, cur, idx) => {
acc[cur] = contentRow[idx] ?? '';
return acc;
}, {}),View on GitHub (pinned to d9bb2b0142)