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.

Solutions

  1. Pass the spec's path (absolute, or relative to workspace) from the renderer.
  2. Ensure the spec is registered in workspace.yml with a non-empty path.
  3. 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

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


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/5202ffbac63f7d78. Report an issue: GitHub.

Appendix: 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)