usebruno/bruno · error · BrunoError
Failed to read ${file.name}: ${err.message}
Error message
Failed to read ${file.name}: ${err.message} What it means
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.
Source
Thrown at packages/bruno-app/src/utils/importers/file-reader.js:59
};
export const readMultipleFiles = async (files) => {
if (!files || files.length === 0) {
throw new BrunoError('No files selected');
}
const parsedFiles = [];
for (const file of files) {
if (!file.name.toLowerCase().endsWith('.json')) {
throw new BrunoError(`Invalid file type: ${file.name}. Only JSON files are supported.`);
}
try {
const parsedFile = await readFile(file);
parsedFiles.push(parsedFile);
} catch (err) {
throw new BrunoError(`Failed to read ${file.name}: ${err.message}`);
}
}
return parsedFiles;
};
View on GitHub (pinned to 9bdd81c7bd)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
const text = await file.text();
try { JSON.parse(text); } catch (e) { throw new Error(`${file.name} is invalid JSON: ${e.message}`); } Try / catch
try {
await readMultipleFiles(files);
} catch (err) {
const m = err.message.match(/Failed to read (.*?): (.*)/);
if (m) console.error(`${m[1]}: ${m[2]}`);
throw err;
} Prevention
- 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.
When it happens
Trigger: A selected .json file that fails JSON.parse (syntax error) or triggers a FileReader error (permission, read failure). The wrapper names the file.
Common situations: One JSON file among several is corrupted, has trailing commas/comments, or is unreadable due to permissions; the rest import fine.
Related errors
- Failed to parse the file – ensure it is valid JSON or YAML
- Failed to process ${parsedFile.fileName}: ${err.message}
- Invalid environment: expected an object
- Invalid environment: missing or invalid variables array
- Invalid variable at index ${index}: expected an object
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/5f846cbb930145a6.
Report an issue: GitHub.