{"record":{"id":"c5d8edc73a644462","repo":"usebruno/bruno","slug":"api-spec-file-not-found","errorCode":null,"errorMessage":"API spec file not found.","messagePattern":"API spec file not found\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/ipc/mock-server/index.js","lineNumber":48,"sourceCode":"};\n\nconst readWorkspaceSpec = (workspacePath, specPath) => {\n  if (!specPath) {\n    throw new Error('API spec path is required.');\n  }\n\n  validateWorkspacePath(workspacePath);\n\n  const resolvedPath = path.resolve(specPath);\n  const isRegisteredSpec = getWorkspaceApiSpecs(workspacePath)\n    .some((spec) => spec.path && path.resolve(spec.path) === resolvedPath);\n\n  if (!isRegisteredSpec) {\n    throw new Error('API spec is not registered in this workspace.');\n  }\n\n  if (!fs.existsSync(resolvedPath)) {\n    throw new Error('API spec file not found.');\n  }\n\n  return parseSpecContent(fs.readFileSync(resolvedPath, 'utf8'));\n};\n\nconst registerMockServerIpc = (mainWindow) => {\n  mockServer.setMainWindow(mainWindow);\n\n  ipcMain.handle('renderer:mock-server-suggest-port', async (_event, payload = {}) => {\n    try {\n      const startPort = Number(payload.startPort) || undefined;\n      const port = await mockServer.suggestPort(startPort, {\n        additionalUsedPorts: payload.additionalUsedPorts || []\n      });\n      return { success: true, port };\n    } catch (err) {\n      return { success: false, error: err.message };\n    }","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/ipc/mock-server/index.js#L30-L66","documentation":"The spec passed the registration allowlist, but `fs.existsSync(resolvedPath)` is false - the file recorded in workspace.yml no longer exists on disk. A stale registration.","triggerScenarios":"The spec file was moved/renamed/deleted after registration; the workspace is on a removable/remote drive that's unmounted; case-sensitivity mismatch between the recorded path and the filesystem (Linux).","commonSituations":"Refactoring a repo that moved `specs/`; cross-platform path casing; external drive not mounted.","solutions":["Restore or relocate the spec file and update workspace.yml to match.","Re-register the spec at its new path via the UI or addApiSpecToWorkspace.","On a case-sensitive filesystem, fix the casing in workspace.yml to match disk exactly."],"exampleFix":"// before: workspace.yml references specs/petstore.yaml but the file moved to specs/v2/petstore.yaml\n// after: update workspace.yml\nspecs:\n  - name: petstore\n    path: specs/v2/petstore.yaml","handlingStrategy":"validation","validationCode":"const fs = require('fs'), path = require('path');\nconst specOnDisk = (specPath) => fs.existsSync(path.resolve(specPath));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When moving spec files, update workspace.yml in the same change.","Re-validate registered specs on workspace open.","Mind path casing on case-sensitive filesystems."],"tags":["mock-server","openapi","filesystem","stale-config"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}