usebruno/bruno · error · Error

API spec is not registered in this workspace.

Error message

API spec is not registered in this workspace.

What it means

Even with a path, readWorkspaceSpec resolves it and confirms it matches one of the specs registered in the workspace config (`getWorkspaceApiSpecs`). This is an allowlist: only specs the workspace explicitly registered can be read by the mock server, preventing arbitrary file reads via the mock-server channel.

Solutions

  1. Register the spec in the workspace first (addApiSpecToWorkspace, or via the UI).
  2. Make the path you pass resolve identically to the registered entry - both absolute or both relative-to-workspace.
  3. Re-add the spec via the UI if it was removed.

Example fix

// before
readWorkspaceSpec(workspacePath, '/abs/path/to/openapi.yaml'); // not in workspace.yml
// after - register first, then reference by the same resolved path
await addApiSpecToWorkspace(workspacePath, { name: 'petstore', path: 'specs/petstore.yaml' });
readWorkspaceSpec(workspacePath, path.join(workspacePath, 'specs/petstore.yaml'));
Defensive patterns

Strategy: validation

Validate before calling

const path = require('path');
const { getWorkspaceApiSpecs } = require('../../utils/workspace-config');
const isRegistered = (workspacePath, specPath) => {
  const resolved = path.resolve(specPath);
  return getWorkspaceApiSpecs(workspacePath).some(s => s.path && path.resolve(s.path) === resolved);
};

Prevention

When it happens

Trigger: Passing an absolute path to a spec that exists on disk but was never added to workspace.yml's `specs`; a relative-vs-absolute mismatch so `path.resolve` comparison fails; the spec was removed from config but the renderer still references it.

Common situations: Pointing the mock server at an OpenAPI file without registering it first; workspace.yml hand-edited and the spec entry dropped; path stored relative in one place and absolute in another.

Related errors


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

Appendix: source

Thrown at packages/bruno-electron/src/ipc/mock-server/index.js:44

  } 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'));
};

const registerMockServerIpc = (mainWindow) => {
  mockServer.setMainWindow(mainWindow);

  ipcMain.handle('renderer:mock-server-suggest-port', async (_event, payload = {}) => {
    try {
      const startPort = Number(payload.startPort) || undefined;
      const port = await mockServer.suggestPort(startPort, {
        additionalUsedPorts: payload.additionalUsedPorts || []
      });

View on GitHub (pinned to 9bdd81c7bd)