{"record":{"id":"f165026795acd155","repo":"Budibase/budibase","slug":"escalation-escalationid-not-found","errorCode":null,"errorMessage":"Escalation ${escalationId} not found","messagePattern":"Escalation (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/escalation/processors/bull.ts","lineNumber":130,"sourceCode":"    escalationId: string,\n    response?: EscalationResponse\n  ): Promise<void> {\n    await this.resolveWithRetry(escalationId, response)\n  }\n\n  private async resolveWithRetry(\n    escalationId: string,\n    response?: EscalationResponse,\n    maxRetries = 3\n  ): Promise<void> {\n    const db = context.getWorkspaceDB()\n    const docId = getDocId(escalationId)\n\n    for (let attempt = 0; attempt < maxRetries; attempt++) {\n      const doc = await db.tryGet<EscalationContextDoc>(docId)\n\n      if (!doc) {\n        throw new Error(`Escalation ${escalationId} not found`)\n      }\n\n      if (doc.resolution !== \"pending\") {\n        // Another writer already resolved it - nothing to do\n        return\n      }\n\n      const now = new Date().toISOString()\n      try {\n        await db.put({\n          ...doc,\n          resolution: \"resolved\",\n          resolvedAt: now,\n          updatedAt: now,\n          ...(response && { response }),\n        })\n      } catch (err) {\n        if (dbCore.isDocumentConflictError(err) && attempt < maxRetries - 1) {","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/escalation/processors/bull.ts#L112-L148","documentation":"resolveWithRetry loads the escalation context doc (escalation context/{escalationId}) from the workspace DB when resolving an escalation. If the document doesn't exist it throws immediately — there is nothing to resolve. Note the retry loop only retries document-conflict (409) writes; a missing doc is a permanent failure on every attempt.","triggerScenarios":"Calling resolve(escalationId) with an ID that was never created, one whose context doc was deleted (cleanup/TTL purge), an ID from a different workspace/tenant DB, or a typo'd ID.","commonSituations":"Double-clicking an Approve/Reject card after the escalation doc was pruned; resolving an escalation after a test run cleaned up context docs; tenant context not established so getWorkspaceDB() points at the wrong DB; resuming with an escalationId copied from logs of another app.","solutions":["Check the escalationId and ensure the code runs inside the correct workspace/tenant context (doInWorkspace/doInTenant) so the right DB is queried.","Verify the escalation still exists: query the workspace DB for doc id escalation context/{escalationId} before resolving.","If the doc was already cleaned up, treat the resolution as no-op instead of erroring (guard the call with try/catch or an existence check).","If doc purges are causing this, extend the escalation context doc retention period."],"exampleFix":"// before\nawait processor.resolve(escalationId, response) // throws if doc purged\n// after\ntry {\n  await processor.resolve(escalationId, response)\n} catch (err) {\n  if (!/not found$/.test(err.message)) throw err // already gone: ignore\n}","handlingStrategy":"try-catch","validationCode":"const docId = `escalation context${SEPARATOR}${escalationId}`\nconst exists = !!(await workspaceDb.tryGet(docId))\nif (!exists) return // already resolved or purged — nothing to do","typeGuard":null,"tryCatchPattern":"try {\n  await processor.resolve(escalationId, response)\n} catch (err) {\n  if (err.message.endsWith(\"not found\")) {\n    console.warn(\"Escalation already gone, ignoring\", { escalationId })\n    return\n  }\n  throw err\n}","preventionTips":["Always resolve escalations within the correct workspace/tenant context","Treat 'not found' as an idempotent no-op for card-based Approve/Reject flows","Extend context doc retention if escalations can outlive cleanup windows","Verify escalationIds come from the same app's logs/DB"],"tags":["database","document-not-found","escalation","couchdb"],"backgroundTag":"escalation-not-found","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}