usebruno/bruno · warning · Error
Invalid file format. Please select a valid OpenAPI spec in Y
Error message
Invalid file format. Please select a valid OpenAPI spec in YAML or JSON format.
What it means
Thrown by validateApiSpec in the Electron app when the selected file's extension is not .yaml, .yml, or .json. The check is purely extension-based (path.extname, lowercased) and runs before any content parsing. It guards the OpenAPI-spec import flow at the API boundary so only recognized spec file types proceed.
Source
Thrown at packages/bruno-electron/src/app/apiSpecs.js:23
const { generateUidBasedOnHash } = require('../utils/common');
const { parseApiSpecContent } = require('../utils/apiSpecs');
const {
addApiSpecToWorkspace,
readWorkspaceConfig,
getWorkspaceUid
} = require('../utils/workspace-config');
const DEFAULT_WORKSPACE_NAME = 'My Workspace';
const INVALID_EXTENSION_MESSAGE
= 'Invalid file format. Please select a valid OpenAPI spec in YAML or JSON format.';
const VALID_API_SPEC_EXTENSIONS = ['.yaml', '.yml', '.json'];
const validateApiSpec = (filePath) => {
const ext = path.extname(filePath).toLowerCase();
if (!VALID_API_SPEC_EXTENSIONS.includes(ext)) {
throw new Error(INVALID_EXTENSION_MESSAGE);
}
};
const prepareWorkspaceConfigForClient = (workspaceConfig, isDefault) => {
if (isDefault) {
return {
...workspaceConfig,
name: DEFAULT_WORKSPACE_NAME,
type: 'default'
};
}
return workspaceConfig;
};
const openApiSpecDialog = async (win, watcher, options = {}) => {
const { filePaths } = await dialog.showOpenDialog(win, {
properties: ['openFile', 'createFile'],
filters: [{ name: 'OpenAPI Spec', extensions: ['yaml', 'yml', 'json'] }]View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Rename or re-save the spec with a .yaml, .yml, or .json extension.
- If the content is valid YAML/JSON, copy it into a correctly named file.
- When calling openApiSpec programmatically, ensure the path ends with a supported extension before invoking.
Example fix
// before
openApiSpec(win, watcher, '/tmp/spec.txt');
// after
const supported = ['.yaml', '.yml', '.json'];
if (!supported.includes(path.extname('/tmp/spec.txt').toLowerCase())) {
throw new Error('Rename the file to .yaml/.yml/.json before importing');
} Defensive patterns
Strategy: validation
Validate before calling
const VALID = ['.yaml', '.yml', '.json'];
const ext = path.extname(filePath).toLowerCase();
if (!VALID.includes(ext)) {
throw new Error('Rename the file to .yaml, .yml, or .json before importing.');
} Type guard
const hasValidApiSpecExtension = (p) => ['.yaml', '.yml', '.json'].includes(path.extname(p).toLowerCase());
Prevention
- Save OpenAPI specs with a .yaml/.yml/.json extension.
- Configure the dialog filters (already set) so users cannot pick other types.
- When scripting imports, assert the extension before calling openApiSpec.
When it happens
Trigger: User picks a file with an unsupported extension (.txt, .xml, .wsdl, no extension, .postman_collection) in the OpenAPI spec dialog; programmatic call to openApiSpec with a path whose extension is outside the allow-list.
Common situations: A spec saved with a .txt extension; a Postman/WSDL file selected by mistake; case sensitivity on case-sensitive filesystems (handled by toLowerCase, but the ext itself must be in the list); a file with no extension.
Related errors
- API spec path is required.
- API spec is not registered in this workspace.
- Workspace path is required
- INVALID_REQUEST
- Workspace path not found
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/60289650b934fa52.
Report an issue: GitHub.