{"record":{"id":"ad04d7c287466335","repo":"paperclipai/paperclip","slug":"session-not-found","errorCode":"session_not_found","errorMessage":"Tool gateway session not found","messagePattern":"Tool gateway session not found","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":404,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":10815,"sourceCode":"        actorId?: string;\n        agentId?: string | null;\n        runId?: string | null;\n      };\n      agentScope?: { agentId: string; runId?: string | null } | null;\n    }) {\n      const now = input.revokedAt ?? new Date();\n      const [existing] = await db\n        .select()\n        .from(toolGatewaySessions)\n        .where(\n          and(\n            eq(toolGatewaySessions.companyId, input.companyId),\n            eq(toolGatewaySessions.id, input.sessionId),\n          ),\n        )\n        .limit(1);\n      if (!existing) {\n        throw new ToolGatewayHttpError(\n          404,\n          \"Tool gateway session not found\",\n          \"session_not_found\",\n        );\n      }\n      if (input.agentScope) {\n        const runMatches = input.agentScope.runId\n          ? existing.runId === input.agentScope.runId\n          : true;\n        if (existing.agentId !== input.agentScope.agentId || !runMatches) {\n          throw new ToolGatewayHttpError(\n            403,\n            \"Tool gateway session is outside the authenticated agent scope\",\n            \"session_scope_mismatch\",\n          );\n        }\n      }\n      const [session] = await db","sourceCodeStart":10797,"sourceCodeEnd":10833,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L10797-L10833","documentation":"Session revocation/management lookup: no toolGatewaySessions row exists for the supplied sessionId within the given company. The 404 fires on the company-scoped select before any revocation or mutation happens, covering deleted sessions and cross-company session ids.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:6280 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the gateway session ID; it may have expired or been closed. Re-establish the session."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}