{"record":{"id":"fd170464737b9fb5","repo":"usebruno/bruno","slug":"mock-response-draft-not-found","errorCode":null,"errorMessage":"Mock response draft not found","messagePattern":"Mock response draft not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-app/src/utils/mock-server/mock-responses/editor.js","lineNumber":80,"sourceCode":"  };\n};\n\nconst stripConditionUids = (rules) => {\n  const cloned = cloneDeep(rules || { operator: 'AND', conditions: [] });\n\n  if (Array.isArray(cloned.conditions)) {\n    cloned.conditions = cloned.conditions.map(({ uid, ...condition }) => condition);\n  }\n\n  return cloned;\n};\n\nexport const mockResponseFromEditorItem = (item, responseUid, rules, savedMockResponse = {}) => {\n  const examples = item.draft?.examples || item.examples || [];\n  const example = examples.find((entry) => entry.uid === responseUid);\n\n  if (!example) {\n    throw new Error('Mock response draft not found');\n  }\n\n  return {\n    uid: responseUid,\n    name: example.name || '',\n    description: example.description || '',\n    request: {\n      ...cloneDeep(example.request),\n      url: extractMockResponseRoutePath(example.request?.url)\n    },\n    response: cloneDeep(example.response),\n    rules: stripConditionUids(rules),\n    ...(savedMockResponse.copiedFrom ? { copiedFrom: cloneDeep(savedMockResponse.copiedFrom) } : {})\n  };\n};\n\nexport const findItemForExampleEditor = (state, collectionUid, itemUid) => {\n  const responseUid = getMockResponseUidFromItemUid(itemUid);","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-app/src/utils/mock-server/mock-responses/editor.js#L62-L98","documentation":"Thrown by mockResponseFromEditorItem when no example in item.draft.examples (or item.examples) has a uid equal to the supplied responseUid. It means the editor is asked to render a response tab whose example no longer exists in the item.","triggerScenarios":"Opening a MockResponseTab with a tab.uid that does not match any entry.uid in item.draft.examples or item.examples — e.g. after the example was deleted, after a uid regeneration, or when passing a stale tab reference.","commonSituations":"Deleting an example while its tab is still open, importing/copying an item whose example uids were reset, or a tab persisted with an outdated responseUid after a collection reload.","solutions":["Close the stale MockResponseTab so it is not re-rendered against a missing example.","Re-open the example from the request's Examples list to get a fresh tab.uid.","If automating, verify responseUid exists in (item.draft?.examples || item.examples).map(e => e.uid) before calling."],"exampleFix":"// before\nconst draft = mockResponseFromEditorItem(item, tab.uid, rules, savedMockResponse);\n// after\nconst examples = item.draft?.examples || item.examples || [];\nif (!examples.some(e => e.uid === tab.uid)) {\n  closeTab(tab.uid);\n  return;\n}\nconst draft = mockResponseFromEditorItem(item, tab.uid, rules, savedMockResponse);","handlingStrategy":"type-guard","validationCode":"const examples = item.draft?.examples || item.examples || [];\nif (!examples.some(e => e.uid === responseUid)) {\n  throw new Error('Response tab is stale; close and reopen the example');\n}","typeGuard":"function exampleExists(item, responseUid) {\n  const examples = item?.draft?.examples || item?.examples || [];\n  return examples.some(e => e.uid === responseUid);\n}","tryCatchPattern":"try {\n  mockResponseFromEditorItem(item, responseUid, rules, savedMockResponse);\n} catch (err) {\n  if (err.message === 'Mock response draft not found') closeTab(responseUid);\n  throw err;\n}","preventionTips":["Close MockResponseTabs when their example is deleted.","Verify responseUid exists in item.examples before opening the tab.","Re-open examples from the Examples list to get a fresh uid after a reload."],"tags":["mock-server","editor","uid","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}