usebruno/bruno · error · Error

Mock response draft not found

Error message

Mock response draft not found

What it means

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.

Source

Thrown at packages/bruno-app/src/utils/mock-server/mock-responses/editor.js:80

  };
};

const stripConditionUids = (rules) => {
  const cloned = cloneDeep(rules || { operator: 'AND', conditions: [] });

  if (Array.isArray(cloned.conditions)) {
    cloned.conditions = cloned.conditions.map(({ uid, ...condition }) => condition);
  }

  return cloned;
};

export const mockResponseFromEditorItem = (item, responseUid, rules, savedMockResponse = {}) => {
  const examples = item.draft?.examples || item.examples || [];
  const example = examples.find((entry) => entry.uid === responseUid);

  if (!example) {
    throw new Error('Mock response draft not found');
  }

  return {
    uid: responseUid,
    name: example.name || '',
    description: example.description || '',
    request: {
      ...cloneDeep(example.request),
      url: extractMockResponseRoutePath(example.request?.url)
    },
    response: cloneDeep(example.response),
    rules: stripConditionUids(rules),
    ...(savedMockResponse.copiedFrom ? { copiedFrom: cloneDeep(savedMockResponse.copiedFrom) } : {})
  };
};

export const findItemForExampleEditor = (state, collectionUid, itemUid) => {
  const responseUid = getMockResponseUidFromItemUid(itemUid);

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Close the stale MockResponseTab so it is not re-rendered against a missing example.
  2. Re-open the example from the request's Examples list to get a fresh tab.uid.
  3. If automating, verify responseUid exists in (item.draft?.examples || item.examples).map(e => e.uid) before calling.

Example fix

// before
const draft = mockResponseFromEditorItem(item, tab.uid, rules, savedMockResponse);
// after
const examples = item.draft?.examples || item.examples || [];
if (!examples.some(e => e.uid === tab.uid)) {
  closeTab(tab.uid);
  return;
}
const draft = mockResponseFromEditorItem(item, tab.uid, rules, savedMockResponse);
Defensive patterns

Strategy: type-guard

Validate before calling

const examples = item.draft?.examples || item.examples || [];
if (!examples.some(e => e.uid === responseUid)) {
  throw new Error('Response tab is stale; close and reopen the example');
}

Type guard

function exampleExists(item, responseUid) {
  const examples = item?.draft?.examples || item?.examples || [];
  return examples.some(e => e.uid === responseUid);
}

Try / catch

try {
  mockResponseFromEditorItem(item, responseUid, rules, savedMockResponse);
} catch (err) {
  if (err.message === 'Mock response draft not found') closeTab(responseUid);
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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