{"record":{"id":"807e1413b997247e","repo":"Kong/insomnia","slug":"upload-json-file-can-not-be-parsed","errorCode":null,"errorMessage":"Upload JSON file can not be parsed","messagePattern":"Upload JSON file can not be parsed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/insomnia-inso/src/cli.ts","lineNumber":229,"sourceCode":"  const content = await readFileFromPathOrUrl(pathOrUrl);\n  if (!content) {\n    return transformIterationDataToEnvironmentList([envAsObject]);\n  }\n  const list = getListFromFileOrUrl(content, fileType).map(data => ({ ...data, ...envAsObject }));\n  return transformIterationDataToEnvironmentList(list);\n};\nconst getListFromFileOrUrl = (content: string, fileType?: string): Record<string, string>[] => {\n  if (fileType === 'json') {\n    try {\n      const jsonDataContent = JSON.parse(content);\n      if (Array.isArray(jsonDataContent)) {\n        return jsonDataContent.filter(\n          data => data && typeof data === 'object' && !Array.isArray(data) && data !== null,\n        );\n      }\n      throw new Error('Invalid JSON file uploaded, JSON file must be array of key-value pairs.');\n    } catch {\n      throw new Error('Upload JSON file can not be parsed');\n    }\n  } else if (fileType === 'csv') {\n    // Replace CRLF (Windows line break) and CR (Mac link break) with \\n, then split into csv arrays\n    const csvRows = content\n      .replace(/\\r\\n|\\r/g, '\\n')\n      .split('\\n')\n      .map(row => row.split(','));\n    // at least 2 rows required for csv\n    if (csvRows.length > 1) {\n      const csvHeaders = csvRows[0];\n      const csvContentRows = csvRows.slice(1);\n      return csvContentRows.map(contentRow =>\n        csvHeaders.reduce((acc: Record<string, any>, cur, idx) => {\n          acc[cur] = contentRow[idx] ?? '';\n          return acc;\n        }, {}),\n      );\n    }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/Kong/insomnia/blob/d9bb2b0142600f21309832daea3317942d285984/packages/insomnia-inso/src/cli.ts#L211-L247","documentation":"Error \"Upload JSON file can not be parsed\" thrown in Kong/insomnia.","triggerScenarios":"Thrown at packages/insomnia-inso/src/cli.ts:229 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":"d9bb2b0142600f21309832daea3317942d285984","analyzedAt":"2026-08-26T18:04:05.187Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}