{"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":1829,"sourceCode":"      throw new ToolGatewayHttpError(\n        401,\n        \"Tool gateway session is expired or invalid\",\n        \"session_invalid\",\n      );\n    }\n\n    if (row.revokedAt) {\n      await writeSessionAuthFailure(row, \"session_revoked\");\n      throw new ToolGatewayHttpError(\n        401,\n        \"Tool gateway session is expired or invalid\",\n        \"session_revoked\",\n      );\n    }\n\n    if (row.expiresAt.getTime() <= Date.now()) {\n      await writeSessionAuthFailure(row, \"session_expired\");\n      throw new ToolGatewayHttpError(\n        401,\n        \"Tool gateway session is expired or invalid\",\n        \"session_expired\",\n      );\n    }\n\n    await assertSessionRunIsActive(row);\n\n    const now = new Date();\n    await db\n      .update(toolGatewaySessions)\n      .set({ lastUsedAt: now, updatedAt: now })\n      .where(eq(toolGatewaySessions.id, row.id));\n\n    const session = gatewaySessionFromRow({\n      ...row,\n      lastUsedAt: now,\n      updatedAt: now,","sourceCodeStart":1811,"sourceCodeEnd":1847,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/services/tool-gateway.ts#L1811-L1847","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":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}