{"record":{"id":"3c4caef57cf3e3e8","repo":"affaan-m/ECC","slug":"session-not-found-session-id-3c4cae","errorCode":null,"errorMessage":"Session not found: {session_id}","messagePattern":"Session not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/session/manager.rs","lineNumber":1475,"sourceCode":"            format!(\n                \"Queued manual merge on {path}; paused later session {} until merge review against {}\",\n                latest.session_id, other.session_id\n            ),\n        ),\n    }\n}\n\npub fn record_tool_call(\n    db: &StateStore,\n    session_id: &str,\n    tool_name: &str,\n    input_summary: &str,\n    output_summary: &str,\n    duration_ms: u64,\n) -> Result<ToolLogEntry> {\n    let session = db\n        .get_session(session_id)?\n        .ok_or_else(|| anyhow::anyhow!(\"Session not found: {session_id}\"))?;\n\n    let event = ToolCallEvent::new(\n        session.id.clone(),\n        tool_name,\n        input_summary,\n        output_summary,\n        duration_ms,\n    );\n    let entry = log_tool_call(db, &event)?;\n    db.increment_tool_calls(&session.id)?;\n\n    Ok(entry)\n}\n\npub fn query_tool_calls(\n    db: &StateStore,\n    session_id: &str,\n    page: u64,","sourceCodeStart":1457,"sourceCodeEnd":1493,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/session/manager.rs#L1457-L1493","documentation":"The record_tool_call function looks up a session by ID in the state store to attach a tool-call log entry. If no session with that ID exists in the database, it bails. The session must exist because the tool-call event and the tool-call counter increment are both keyed on the session.","triggerScenarios":"Calling record_tool_call(db, session_id, ...) with a session_id that db.get_session() cannot find — the session was never created, was already deleted, or the ID is misspelled.","commonSituations":"Session was deleted between spawn and tool-call logging. DB file was reset or corrupted. Passing a stale session ID from a previous run. Typo or truncated session ID.","solutions":["Verify the session exists with db.get_session(session_id) before calling record_tool_call","Check that the session was not deleted by a concurrent delete_session call","Ensure the DB path in cfg.db_path points to the correct state store file","If logging tool calls for a session that may have been cleaned up, handle the NotFound case gracefully rather than propagating the error"],"exampleFix":"// before\nlet entry = record_tool_call(db, session_id, tool, input, output, duration)?;\n\n// after\nif db.get_session(session_id)?.is_none() {\n    tracing::warn!(\"session {session_id} no longer exists, skipping tool call log\");\n    return Ok(Default::default());\n}\nlet entry = record_tool_call(db, session_id, tool, input, output, duration)?;","handlingStrategy":"validation","validationCode":"if db.get_session(session_id)?.is_none() {\n    tracing::warn!(\"session {session_id} not found, skipping tool call recording\");\n    return Ok(Default::default());\n}\nlet entry = record_tool_call(db, session_id, tool_name, input, output, duration)?;","typeGuard":null,"tryCatchPattern":"match record_tool_call(db, session_id, tool, input, output, duration) {\n    Ok(entry) => Ok(entry),\n    Err(e) if e.to_string().contains(\"Session not found\") => {\n        tracing::warn!(\"session {session_id} gone, tool call not recorded\");\n        Ok(Default::default())\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Always verify session existence before recording tool calls from async/lazy contexts","Avoid passing raw session IDs across process boundaries where deletion races exist","Use a session registry that prevents deletion while tool calls are in flight"],"tags":["sessions","tool-calls","database","not-found"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}