Kong/insomnia · error
Invalid JSON file uploaded, JSON file must be array of key-v
Error message
Invalid JSON file uploaded, JSON file must be array of key-value pairs.
What it means
Error "Invalid JSON file uploaded, JSON file must be array of key-value pairs." thrown in Kong/insomnia.
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)
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.