{"record":{"id":"8651591a10027a07","repo":"usebruno/bruno","slug":"mock-server-id-is-required-865159","errorCode":null,"errorMessage":"Mock server id is required.","messagePattern":"Mock server id is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/mock-server/index.js","lineNumber":243,"sourceCode":"      const { workspacePath, workspaceUid, migrateFrom = [] } = payload;\n\n      validateWorkspacePath(workspacePath);\n\n      const instances = listMockServers(workspacePath, workspaceUid, { migrateFrom });\n      return { success: true, instances };\n    } catch (err) {\n      return { success: false, error: err.message };\n    }\n  });\n\n  ipcMain.handle('renderer:mock-server-save-instance', async (_event, payload) => {\n    try {\n      const { workspacePath, instance } = payload;\n\n      validateWorkspacePath(workspacePath);\n\n      if (!instance?.uid) {\n        throw new Error('Mock server id is required.');\n      }\n\n      const savedInstance = saveMockServer(workspacePath, instance);\n      return { success: true, instance: savedInstance };\n    } catch (err) {\n      return { success: false, error: err.message };\n    }\n  });\n\n  ipcMain.handle('renderer:mock-server-delete', async (_event, payload) => {\n    try {\n      deleteMockServer(payload);\n      await mockServer.reloadRoutesFromStore(payload.mockServerUid, payload);\n      return { success: true, mockServerUid: payload.mockServerUid };\n    } catch (err) {\n      return { success: false, error: err.message };\n    }\n  });","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/mock-server/index.js#L225-L261","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Creating a new mock server in the UI and saving before the uid is minted; a refactor that drops uid from the payload.","solutions":["Generate/assign a uid (uuid) on the instance before saving.","Use the create-instance flow first, then save edits.","Validate `instance.uid` in the renderer before invoking."],"exampleFix":"// before\ninvoke('renderer:mock-server-save-instance', { workspacePath, instance: { name, port } });\n// after\nconst uid = crypto.randomUUID();\ninvoke('renderer:mock-server-save-instance', { workspacePath, instance: { uid, name, port } });","handlingStrategy":"validation","validationCode":"const hasUid = (inst) => !!inst && typeof inst.uid === 'string' && inst.uid.length > 0;","typeGuard":"const isMockServerInstance = (x) => !!x && typeof x === 'object' && typeof x.uid === 'string' && x.uid.length > 0;","tryCatchPattern":null,"preventionTips":["Mint a uuid at instance-creation time, never at save time.","Type the IPC payload so a missing uid fails at compile time.","Use the create-instance flow before saving edits."],"tags":["mock-server","validation","ipc","identity"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}