{"record":{"id":"c4e028b9b8445748","repo":"usebruno/bruno","slug":"invalid-file-type-file-name-only-json-files-a","errorCode":null,"errorMessage":"Invalid file type: ${file.name}. Only JSON files are supported.","messagePattern":"Invalid file type: (.+?)\\. Only JSON files are supported\\.","errorType":"validation","errorClass":"BrunoError","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/utils/importers/file-reader.js","lineNumber":52,"sourceCode":"        console.error(err);\n        reject(new BrunoError(`Unable to parse JSON file: ${file.name}`));\n      }\n    };\n    fileReader.onerror = (err) => reject(err);\n    fileReader.readAsText(file);\n  });\n};\n\nexport const readMultipleFiles = async (files) => {\n  if (!files || files.length === 0) {\n    throw new BrunoError('No files selected');\n  }\n\n  const parsedFiles = [];\n\n  for (const file of files) {\n    if (!file.name.toLowerCase().endsWith('.json')) {\n      throw new BrunoError(`Invalid file type: ${file.name}. Only JSON files are supported.`);\n    }\n\n    try {\n      const parsedFile = await readFile(file);\n      parsedFiles.push(parsedFile);\n    } catch (err) {\n      throw new BrunoError(`Failed to read ${file.name}: ${err.message}`);\n    }\n  }\n\n  return parsedFiles;\n};\n","sourceCodeStart":34,"sourceCodeEnd":65,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/utils/importers/file-reader.js#L34-L65","documentation":"Type gate in readMultipleFiles. Fires for any file whose lowercased name does not end with .json. The function only accepts JSON in this path even though the parse path supports YAML elsewhere.","triggerScenarios":"Passing a .yml, .yaml, .txt, .bru, or extensionless file to readMultipleFiles.","commonSituations":"User selects a YAML environment or a Postman/Insomnia export saved without .json, or drops a .bru collection file into the environment importer.","solutions":["Convert/re-save the file with a .json extension and valid JSON content.","Use the appropriate importer for the file type (e.g. collection importer for .bru, YAML-aware path if available).","Filter the file picker to accept only .json: <input accept=\".json\">."],"exampleFix":"<!-- before -->\n<input type=\"file\" multiple />\n<!-- after -->\n<input type=\"file\" multiple accept=\".json,application/json\" />","handlingStrategy":"validation","validationCode":"for (const f of files) {\n  if (!f.name.toLowerCase().endsWith('.json')) {\n    throw new Error(`${f.name} is not .json`);\n  }\n}","typeGuard":"function isJsonFile(file) {\n  return file?.name?.toLowerCase().endsWith('.json');\n}","tryCatchPattern":"try {\n  await readMultipleFiles(files);\n} catch (err) {\n  if (err.message.startsWith('Invalid file type')) {\n    // filter the input to .json or route to a YAML importer\n  }\n  throw err;\n}","preventionTips":["Set <input accept=\".json,application/json\"> so non-JSON files cannot be picked.","Filter the FileList to .json before calling readMultipleFiles.","Use the correct importer for YAML/.bru files."],"tags":["import","filesystem","validation","file-type"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}