{"record":{"id":"5f846cbb930145a6","repo":"usebruno/bruno","slug":"failed-to-read-file-name-err-message","errorCode":null,"errorMessage":"Failed to read ${file.name}: ${err.message}","messagePattern":"Failed to read (.+?): (.+?)","errorType":"exception","errorClass":"BrunoError","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/utils/importers/file-reader.js","lineNumber":59,"sourceCode":"};\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":41,"sourceCodeEnd":65,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/utils/importers/file-reader.js#L41-L65","documentation":"Per-file catch in the readMultipleFiles loop. Fires when readFile() rejects for a given file (JSON.parse error inside the FileReader.onload, or fileReader.onerror). The original message is appended.","triggerScenarios":"A selected .json file that fails JSON.parse (syntax error) or triggers a FileReader error (permission, read failure). The wrapper names the file.","commonSituations":"One JSON file among several is corrupted, has trailing commas/comments, or is unreadable due to permissions; the rest import fine.","solutions":["Open the named file with a JSON validator to find the syntax error.","Re-export or repair the file, then retry the import.","Import files individually to isolate which one is malformed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const text = await file.text();\ntry { JSON.parse(text); } catch (e) { throw new Error(`${file.name} is invalid JSON: ${e.message}`); }","typeGuard":null,"tryCatchPattern":"try {\n  await readMultipleFiles(files);\n} catch (err) {\n  const m = err.message.match(/Failed to read (.*?): (.*)/);\n  if (m) console.error(`${m[1]}: ${m[2]}`);\n  throw err;\n}","preventionTips":["Pre-validate each file's JSON syntax before import.","Import files individually to isolate the malformed one.","Re-export corrupted files from their source tool."],"tags":["import","filesystem","json","parsing","error-wrapping"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}