{"record":{"id":"dcf6604efcf3f394","repo":"thedotmack/claude-mem","slug":"session-sessiondbid-not-found","errorCode":null,"errorMessage":"Session ${sessionDbId} not found","messagePattern":"Session (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/services/worker/DatabaseManager.ts","lineNumber":116,"sourceCode":"    }\n    return this.db;\n  }\n\n  getSessionById(sessionDbId: number): {\n    id: number;\n    content_session_id: string;\n    memory_session_id: string | null;\n    project: string;\n    platform_source: string;\n    user_prompt: string;\n    custom_title: string | null;\n    status: string;\n    observed_model: string | null;\n    observed_billing: string | null;\n  } {\n    const session = this.getSessionStore().getSessionById(sessionDbId);\n    if (!session) {\n      throw new Error(`Session ${sessionDbId} not found`);\n    }\n    return session;\n  }\n\n}\n","sourceCodeStart":98,"sourceCodeEnd":122,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/worker/DatabaseManager.ts#L98-L122","documentation":"DatabaseManager.getSessionById delegates to the session store and throws when no session row exists for the given numeric sessionDbId. It is a strict accessor: callers that require an existing session (to attach prompts, observations, etc.) get a loud failure rather than a null to mishandle downstream.","triggerScenarios":"Calling getSessionById(sessionDbId) with an id that is not in the sessions table — deleted session row, stale id from a previous DB, or an id belonging to a different database file.","commonSituations":"Worker resumed after the DB was reset/migrated; message referencing a session id from a removed record; concurrent process deleted the session; hardcoding an id from logs against a fresh DB.","solutions":["Verify the sessionDbId against the sessions table (SELECT id FROM sessions ...).","Look up the session again by its current id rather than reusing a cached/stale id.","If sessions may legitimately disappear, use the store's nullable getter and handle null.","Confirm the worker points at the intended DB (~/.claude-mem/claude-mem.db), not another copy."],"exampleFix":"// before\nconst s = db.getSessionById(id); // throws\n// after\nconst s = db.getSessionStore().getSessionById(id);\nif (!s) return; // or recreate the session","handlingStrategy":"try-catch","validationCode":"const exists = db.getSessionStore().getSessionById(sessionDbId);\nif (!exists) return; // handle missing session before strict call","typeGuard":null,"tryCatchPattern":"try { const s = db.getSessionById(id); } catch (e) { if (e.message.startsWith('Session ') && e.message.endsWith(' not found')) { /* recreate or skip */ } }","preventionTips":["Use nullable getters when absence is an expected case.","Purge cached session ids when the DB is reset or migrated.","Log the id and DB path when a session lookup fails."],"tags":["database","session","not-found"],"backgroundTag":"record-not-found","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}