{"record":{"id":"e31ddffad958cba4","repo":"paperclipai/paperclip","slug":"approval-request-missing","errorCode":"approval_request_missing","errorMessage":"Approval request was not created","messagePattern":"Approval request was not created","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":500,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":1556,"sourceCode":"    errorCode?: string | null;\n    errorMessage?: string | null;\n    resultSummary?: string | null;\n  }): Promise<void> {\n    const [linked] = await db\n      .select({\n        companyId: toolActionRequests.companyId,\n        interactionId: toolActionRequests.interactionId,\n      })\n      .from(toolActionRequests)\n      .where(eq(toolActionRequests.id, input.actionRequestId))\n      .limit(1);\n    if (!linked?.interactionId) return;\n\n    const [interaction] = await db\n      .select({\n        status: issueThreadInteractions.status,\n        result: issueThreadInteractions.result,\n      })\n      .from(issueThreadInteractions)\n      .where(and(\n        eq(issueThreadInteractions.id, linked.interactionId),\n        eq(issueThreadInteractions.companyId, linked.companyId),\n      ))\n      .limit(1);\n    if (!interaction) return;\n\n    const currentResult = interaction.result && typeof interaction.result === \"object\"\n      ? interaction.result as unknown as Record<string, unknown>\n      : null;\n    const outcome = typeof currentResult?.outcome === \"string\"\n      ? currentResult.outcome\n      : interaction.status === \"accepted\"\n        ? \"accepted\"\n        : interaction.status === \"rejected\"\n          ? \"rejected\"\n          : interaction.status === \"expired\" || input.status === \"expired\"","sourceCodeStart":1538,"sourceCodeEnd":1574,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/server/src/services/tool-gateway.ts#L1538-L1574","documentation":"Consistency guard after the policy engine returned require_approval: the expected tool_action_requests row was never created. The invocation is set to denied with errorCode approval_request_missing, indicating an internal invariant break between the policy decision and action-request creation rather than a client input problem.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1556 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Approval creation failed internally. Retry; if persistent, check server logs for the approval insert failure."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}