{"record":{"id":"db60296e97793a90","repo":"paperclipai/paperclip","slug":"session-expired","errorCode":"session_expired","errorMessage":"Tool gateway session is expired or invalid","messagePattern":"Tool gateway session is expired or invalid","errorType":"http","errorClass":"ToolGatewayHttpError","httpStatus":401,"severity":"error","filePath":"server/src/services/tool-gateway.ts","lineNumber":1305,"sourceCode":"            ? input.details.gatewayTokenId\n            : null,\n        gatewayPublicId: typeof input.details.gatewayPublicId === \"string\" ? input.details.gatewayPublicId : null,\n        clientName: typeof input.details.clientName === \"string\" ? input.details.clientName : null,\n        correlationId: typeof input.details.correlationId === \"string\" ? input.details.correlationId : null,\n        connectionId: typeof input.details.connectionId === \"string\" ? input.details.connectionId : null,\n        catalogEntryId: typeof input.details.catalogEntryId === \"string\" ? input.details.catalogEntryId : null,\n        actorType: input.actorType ?? input.session?.actorType ?? (input.agentId ? \"agent\" : \"system\"),\n        actorId: input.actorId ?? input.session?.actorId ?? input.agentId ?? input.session?.gatewayTokenId ?? input.companyId,\n        action: dedicatedAuditAction,\n        outcome: dedicatedOutcome,\n        reasonCode: typeof input.details.reasonCode === \"string\" ? input.details.reasonCode : null,\n        details: {\n          source: input.action,\n          agentId: input.agentId,\n          issueId: input.issueId,\n          projectId: input.session?.projectId ?? null,\n          runId: input.runId,\n          gatewaySessionId: input.session?.id ?? null,\n          gatewayId: input.session?.gatewayId ?? null,\n          gatewayPublicId: input.session?.gatewayPublicId ?? null,\n          gatewayName: input.session?.gatewayName ?? null,\n          gatewayTokenId: input.session?.gatewayTokenId ?? null,\n          ...input.details,\n        },\n      });\n    } catch (error) {\n      await recordToolRuntimeAuditWriteFailure(db, input.companyId);\n      throw error;\n    }\n\n    const entityType = input.issueId ? \"issue\" : input.session?.gatewayId ? \"tool_mcp_gateway\" : \"agent\";\n    const entityId = input.issueId ?? input.session?.gatewayId ?? input.agentId ?? input.companyId;\n    await logActivity(db, {\n      companyId: input.companyId,\n      actorType: input.actorType ?? input.session?.actorType ?? (input.agentId ? \"agent\" : \"system\"),\n      actorId: input.actorId ?? input.session?.actorId ?? input.agentId ?? input.session?.gatewayTokenId ?? input.companyId,","sourceCodeStart":1287,"sourceCodeEnd":1323,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/server/src/services/tool-gateway.ts#L1287-L1323","documentation":"Sentinel 401 for an unrecognized gateway session token: the token hash matched no active session row. The failure is recorded for the candidate session (when derivable) as session_invalid so operators can audit invalid-token attempts; clients should obtain a fresh session rather than retry the same token.","triggerScenarios":"Thrown at server/src/services/tool-gateway.ts:1305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-establish the tool gateway session (re-authenticate); the session token expired or is invalid."],"exampleFix":null,"handlingStrategy":"try-catch","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"}