usebruno/bruno · error · Error

Mock server id is required.

Error message

Mock server id is required.

What it means

Thrown by getMockServerResponses when the `location` argument has no truthy `mockServerUid`. The function reads mock-server responses from the workspace store keyed by mockServerUid, so without an id it cannot locate the responses block. This is the first of two guards in getMockServerResponses (mockServerUid checked before workspacePath).

Source

Thrown at packages/bruno-electron/src/app/mock-server/mock-response-store.js:302

  const legacyResponses = readLegacyPerServerStore(location);
  if (!legacyResponses.length) {
    return [];
  }

  store.mockServers[mockServerUid] = {
    ...existingBlock,
    legacyMigrated: true,
    responses: legacyResponses
  };
  writeWorkspaceStore(workspacePath, store);

  return legacyResponses;
};

const getMockServerResponses = (location) => {
  if (!location?.mockServerUid) {
    throw new Error('Mock server id is required.');
  }

  if (!location?.workspacePath) {
    throw new Error('Workspace path is required.');
  }

  const store = readWorkspaceStore(location.workspacePath);
  const responses = store.mockServers?.[location.mockServerUid]?.responses;

  if (Array.isArray(responses) && responses.length > 0) {
    return responses;
  }

  return migrateLegacyResponses(location);
};

const setMockServerResponses = (location, responses) => {
  const store = readWorkspaceStore(location.workspacePath);

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Ensure the mock server exists (create/save it first via saveMockServer) and pass its uid in location.mockServerUid.
  2. Validate the location object shape before calling: require both mockServerUid and workspacePath.
  3. If the uid came from a route param, confirm the param name maps to mockServerUid.

Example fix

// before
getMockServerResponses({ workspacePath: '/ws' }); // missing mockServerUid

// after
if (!mockServer?.uid) throw new Error('Create the mock server first');
getMockServerResponses({ workspacePath: '/ws', mockServerUid: mockServer.uid });
Defensive patterns

Strategy: validation

Validate before calling

if (!location?.mockServerUid) {
  throw new Error('Create or select a mock server before reading responses.');
}

Type guard

const hasMockServerLocation = (l) => !!l && typeof l.mockServerUid === 'string' && !!l.mockServerUid;

Prevention

When it happens

Trigger: Calling getMockServerResponses({}) , getMockServerResponses(null), or getMockServerResponses({ workspacePath }) with the uid omitted/empty; a caller passing a partial location object built from an incomplete IPC payload.

Common situations: Frontend IPC handler forwarding a user action before the mock server was created/saved; a deleted mock server whose id reference was cleared; passing the workspaceUid in place of mockServerUid by mistake.

Related errors


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