{"record":{"id":"1767579aabfe08c8","repo":"Budibase/budibase","slug":"escalation-escalationid-not-found-176757","errorCode":null,"errorMessage":"Escalation ${escalationId} not found","messagePattern":"Escalation (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/server/src/sdk/workspace/escalations.ts","lineNumber":163,"sourceCode":"        doc != null && doc.escalationId === escalationId\n    )\n}\n\n// Handles an incoming response from a recipient - writes the notification doc,\n// runs the resolution strategy, and triggers resolve if the strategy returns truthy.\n// NOTE: as notification channels grow, a dedicated notification processor may be\n// a better home for this responsibility than the escalation processor.\nexport async function respond(\n  escalationId: string,\n  notificationDocId: string,\n  response: EscalationResponse,\n  resolve: (escalationId: string, response: EscalationResponse) => Promise<void>\n): Promise<EscalationRespondResult> {\n  const db = context.getWorkspaceDB()\n\n  const contextDoc = await getContextDoc(escalationId)\n  if (!contextDoc) {\n    throw new Error(`Escalation ${escalationId} not found`)\n  }\n  if (contextDoc.resolution !== \"pending\") {\n    return { status: \"closed\" }\n  }\n\n  const notifDoc = await db.tryGet<EscalationNotificationDoc>(notificationDocId)\n  if (!notifDoc) {\n    throw new Error(`Notification doc ${notificationDocId} not found`)\n  }\n  // Ensure the notification actually belongs to this escalation - stops a forged\n  // payload pairing a valid notificationDocId with a different escalationId.\n  if (notifDoc.escalationId !== escalationId) {\n    console.warn(\n      \"Escalation respond: notification does not belong to escalation (possible forged payload)\",\n      {\n        escalationId,\n        notificationDocId,\n        notifEscalationId: notifDoc.escalationId,","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/escalations.ts#L145-L181","documentation":"Thrown by the escalation respond flow when no context document exists for the given escalationId. The resolver looks up the escalation's context doc in the workspace DB before applying a response; if it is missing, the escalation either never existed, was deleted, or the ID is wrong, and the response cannot be recorded.","triggerScenarios":"Calling respond(escalationId, response, resolve) with an escalationId that has no corresponding context doc in the current workspace database — wrong ID, wrong workspace/tenant context, or the escalation docs were purged.","commonSituations":"Stale notification payloads replayed after the escalation was cleaned up; cross-tenant calls where the escalation lives in a different workspace DB; typos or truncated IDs from log scraping.","solutions":["Check the escalationId value and confirm the escalation exists via get/fetch before responding","Ensure the call runs inside the correct workspace/tenant context so context.getWorkspaceDB() points at the DB holding the escalation doc","If the escalation was legitimately removed, discard the stale response instead of retrying"],"exampleFix":"// before\nawait escalations.respond(staleIdFromOldNotification, response, resolve)\n// after\nconst ctx = await getContextDoc(staleIdFromOldNotification)\nif (ctx) await escalations.respond(staleIdFromOldNotification, response, resolve)","handlingStrategy":"try-catch","validationCode":"const db = context.getWorkspaceDB()\nconst exists = !!(await db.tryGet<EscalationContextDoc>(escalationDocId(escalationId)))\nif (!exists) throw new Error(`Escalation ${escalationId} does not exist`)","typeGuard":null,"tryCatchPattern":"try {\n  await escalations.respond(escalationId, response, resolve)\n} catch (err) {\n  if (err.message.includes(\"not found\")) {\n    // stale or unknown escalation — drop the response rather than retry\n    return { status: \"discarded\" }\n  }\n  throw err\n}","preventionTips":["Only respond to escalation IDs received directly from the escalation notification payload","Run respond calls within the workspace context that owns the escalation","Handle cleanup: assume IDs from old notifications may have been purged"],"tags":["escalations","not-found","database"],"backgroundTag":"resource-not-found","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}