usebruno/bruno · error · Error

Mock server id is required.

Error message

Mock server id is required.

What it means

`renderer:mock-server-save-instance` persists a mock server instance and checks `instance?.uid`. A falsy uid means there is no identity to save under, so it rejects - the uid is the primary key for the record.

Source

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

      const { workspacePath, workspaceUid, migrateFrom = [] } = payload;

      validateWorkspacePath(workspacePath);

      const instances = listMockServers(workspacePath, workspaceUid, { migrateFrom });
      return { success: true, instances };
    } catch (err) {
      return { success: false, error: err.message };
    }
  });

  ipcMain.handle('renderer:mock-server-save-instance', async (_event, payload) => {
    try {
      const { workspacePath, instance } = payload;

      validateWorkspacePath(workspacePath);

      if (!instance?.uid) {
        throw new Error('Mock server id is required.');
      }

      const savedInstance = saveMockServer(workspacePath, instance);
      return { success: true, instance: savedInstance };
    } catch (err) {
      return { success: false, error: err.message };
    }
  });

  ipcMain.handle('renderer:mock-server-delete', async (_event, payload) => {
    try {
      deleteMockServer(payload);
      await mockServer.reloadRoutesFromStore(payload.mockServerUid, payload);
      return { success: true, mockServerUid: payload.mockServerUid };
    } catch (err) {
      return { success: false, error: err.message };
    }
  });

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Generate/assign a uid (uuid) on the instance before saving.
  2. Use the create-instance flow first, then save edits.
  3. Validate `instance.uid` in the renderer before invoking.

Example fix

// before
invoke('renderer:mock-server-save-instance', { workspacePath, instance: { name, port } });
// after
const uid = crypto.randomUUID();
invoke('renderer:mock-server-save-instance', { workspacePath, instance: { uid, name, port } });
Defensive patterns

Strategy: validation

Validate before calling

const hasUid = (inst) => !!inst && typeof inst.uid === 'string' && inst.uid.length > 0;

Type guard

const isMockServerInstance = (x) => !!x && typeof x === 'object' && typeof x.uid === 'string' && x.uid.length > 0;

Prevention

When it happens

Trigger: Calling save-instance with an instance that has no uid (new object before id generation); `instance` itself undefined so `undefined?.uid`; a form submit fired before the uid was assigned.

Common situations: Creating a new mock server in the UI and saving before the uid is minted; a refactor that drops uid from the payload.

Related errors


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