{"record":{"id":"55137969ce70f22c","repo":"thedotmack/claude-mem","slug":"session-not-found","errorCode":"session_not_found","errorMessage":"session_not_found","messagePattern":"session_not_found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"src/server/compat/SessionsSummarizeAdapter.ts","lineNumber":122,"sourceCode":"      teamId,\n      projectId,\n      contentSessionId: data.contentSessionId,\n      platformSource,\n      agentId: null,\n      agentType: null,\n    });\n\n    const result = await this.options.endSession.end({\n      sessionId: session.id,\n      projectId,\n      teamId,\n      source: 'http_post_api_sessions_summarize',\n      apiKeyId: req.authContext?.apiKeyId ?? null,\n      actorId: null,\n      sourceAdapter: 'claude-code-compat',\n    });\n    if (!result.session) {\n      res.status(404).json({ status: 'not_found', reason: 'session_not_found' });\n      return;\n    }\n    res.json({\n      status: 'queued',\n      sessionId: session.id,\n      serverSessionId: session.id,\n      generationJobId: result.outbox?.id ?? null,\n      transport: result.enqueueState,\n    });\n  }\n\n  private asyncHandler(fn: (req: Request, res: Response) => Promise<void> | void) {\n    return (req: Request, res: Response, next: (err?: unknown) => void): void => {\n      Promise.resolve(fn(req, res)).catch(next);\n    };\n  }\n}\n","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/server/compat/SessionsSummarizeAdapter.ts#L104-L140","documentation":"404 from the compat summarize route when the endSession pipeline resolves to no session (result.session is null). The adapter looked up the session by contentSessionId within the key's team/project and either found nothing or the end operation could not materialize a session row; the response keeps the legacy shape { status: 'not_found', reason: 'session_not_found' }.","triggerScenarios":"POST /api/sessions/summarize with a contentSessionId never created in that team/project; summarizing a session whose id belongs to a different project than the key's scope; calling summarize twice where the first call ended and removed/flagged the session so a second call cannot resolve it.","commonSituations":"Client regenerates session ids per run and summarizes an id from a stale run; key's projectId does not match the project that ingested the session's events; environment mismatch (test key against prod data or vice versa).","solutions":["Verify the contentSessionId was actually ingested: check that events for it were accepted (201 from /v1/events) under the same team/project as the key.","Confirm the API key's project scope matches the project that owns the session.","Make summarize idempotent on the client: treat 404 session_not_found as terminal, not retryable.","If the session should exist, query the sessions/events listing for that team to see whether it was ended or never created."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm ingestion before summarizing\nconst created = await postJson('/v1/events', {\n  projectId, contentSessionId: sid,\n  type: 'session.start', // per schema\n});\nif (created.status !== 201 && created.status !== 200) {\n  throw new Error(`session ${sid} not ingestible; skipping summarize`);\n}","typeGuard":"interface NotFoundBody { status: string; reason: string }\nfunction isSessionNotFound(body: unknown): body is NotFoundBody {\n  return typeof body === 'object' && body !== null &&\n    (body as NotFoundBody).status === 'not_found' && (body as NotFoundBody).reason === 'session_not_found';\n}","tryCatchPattern":"const res = await summarize(sid);\nif (res.status === 404) {\n  const body = await res.json();\n  if (isSessionNotFound(body)) return; // terminal: session absent under this scope\n}","preventionTips":["Summarize only sessions whose start event you saw accepted.","Keep key's project scope identical between ingestion and summarize calls.","Treat 404 as non-retryable to avoid loops."],"tags":["http-404","session-not-found","claude-code-compat","sessions"],"backgroundTag":"session-not-found","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}