usebruno/bruno · error · BrunoError
Invalid file type: ${file.name}. Only JSON files are support
Error message
Invalid file type: ${file.name}. Only JSON files are supported. What it means
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.
Source
Thrown at packages/bruno-app/src/utils/importers/file-reader.js:52
console.error(err);
reject(new BrunoError(`Unable to parse JSON file: ${file.name}`));
}
};
fileReader.onerror = (err) => reject(err);
fileReader.readAsText(file);
});
};
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
- 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">.
Example fix
<!-- before --> <input type="file" multiple /> <!-- after --> <input type="file" multiple accept=".json,application/json" />
Defensive patterns
Strategy: validation
Validate before calling
for (const f of files) {
if (!f.name.toLowerCase().endsWith('.json')) {
throw new Error(`${f.name} is not .json`);
}
} Type guard
function isJsonFile(file) {
return file?.name?.toLowerCase().endsWith('.json');
} Try / catch
try {
await readMultipleFiles(files);
} catch (err) {
if (err.message.startsWith('Invalid file type')) {
// filter the input to .json or route to a YAML importer
}
throw err;
} Prevention
- 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.
When it happens
Trigger: Passing a .yml, .yaml, .txt, .bru, or extensionless file to readMultipleFiles.
Common situations: User selects a YAML environment or a Postman/Insomnia export saved without .json, or drops a .bru collection file into the environment importer.
Related errors
- No files selected
- ZIP file does not exist
- Collection location does not exist
- Invalid environment: expected an object
- Invalid environment: missing or invalid variables array
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/c4e028b9b8445748.
Report an issue: GitHub.