usebruno/bruno · error · Error
API spec path is required.
Error message
API spec path is required.
What it means
`readWorkspaceSpec` loads an OpenAPI spec for the mock server. A falsy `specPath` is rejected up front - the function cannot proceed without knowing which spec to read.
Source
Thrown at packages/bruno-electron/src/ipc/mock-server/index.js:34
saveMockResponse,
saveMockServer,
setMockServerResponses
} = require('../../app/mock-server/mock-response-store');
const getResponses = (location) => listMockResponses(location);
const parseSpecContent = (content) => {
try {
return JSON.parse(content);
} catch {
const yaml = require('js-yaml');
return yaml.load(content);
}
};
const readWorkspaceSpec = (workspacePath, specPath) => {
if (!specPath) {
throw new Error('API spec path is required.');
}
validateWorkspacePath(workspacePath);
const resolvedPath = path.resolve(specPath);
const isRegisteredSpec = getWorkspaceApiSpecs(workspacePath)
.some((spec) => spec.path && path.resolve(spec.path) === resolvedPath);
if (!isRegisteredSpec) {
throw new Error('API spec is not registered in this workspace.');
}
if (!fs.existsSync(resolvedPath)) {
throw new Error('API spec file not found.');
}
return parseSpecContent(fs.readFileSync(resolvedPath, 'utf8'));
};View on GitHub (pinned to 9bdd81c7bd)
Solutions
- Pass the spec's path (absolute, or relative to workspace) from the renderer.
- Ensure the spec is registered in workspace.yml with a non-empty path.
- Validate the payload shape before invoking the mock-server channel.
Example fix
// before readWorkspaceSpec(workspacePath, undefined); // after readWorkspaceSpec(workspacePath, spec.path);
Defensive patterns
Strategy: validation
Validate before calling
const hasSpecPath = (p) => typeof p === 'string' && p.trim().length > 0;
if (!hasSpecPath(specPath)) throw new Error('API spec path is required.'); Prevention
- Require a spec selection in the mock-server UI before any action.
- Validate IPC payloads against a schema at the boundary.
- Ensure spec entries in workspace.yml always carry a non-empty path.
When it happens
Trigger: A mock-server IPC channel calls readWorkspaceSpec with `specPath: undefined/null/''`; the renderer payload is missing the spec path field; a config migration dropped the path.
Common situations: Creating a mock server before selecting a spec; a workspace where the spec entry lost its path.
Related errors
- Mock server id is required.
- Workspace path is required.
- API spec is not registered in this workspace.
- Mock server id is required.
- Could not reach the mock server
AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13).
Data as JSON: /api/errors/5202ffbac63f7d78.
Report an issue: GitHub.