{"record":{"id":"8369ce48aaab22b2","repo":"affaan-m/ECC","slug":"no-sessions-found","errorCode":null,"errorMessage":"No sessions found","messagePattern":"No sessions found","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/main.rs","lineNumber":2913,"sourceCode":"        Some(Commands::RunSession {\n            session_id,\n            task,\n            agent,\n            cwd,\n        }) => {\n            session::manager::run_session(&cfg, &session_id, &task, &agent, &cwd).await?;\n        }\n    }\n\n    Ok(())\n}\n\nfn resolve_session_id(db: &session::store::StateStore, value: &str) -> Result<String> {\n    if value == \"latest\" {\n        return db\n            .get_latest_session()?\n            .map(|session| session.id)\n            .ok_or_else(|| anyhow::anyhow!(\"No sessions found\"));\n    }\n\n    db.get_session(value)?\n        .map(|session| session.id)\n        .ok_or_else(|| anyhow::anyhow!(\"Session not found: {value}\"))\n}\n\nfn sync_runtime_session_metrics(\n    db: &session::store::StateStore,\n    cfg: &config::Config,\n) -> Result<()> {\n    db.refresh_session_durations()?;\n    db.sync_cost_tracker_metrics(&cfg.cost_metrics_path())?;\n    db.sync_tool_activity_metrics(&cfg.tool_activity_metrics_path())?;\n    let _ = session::manager::enforce_session_heartbeats(db, cfg)?;\n    let _ = session::manager::enforce_budget_hard_limits(db, cfg)?;\n    Ok(())\n}","sourceCodeStart":2895,"sourceCodeEnd":2931,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/main.rs#L2895-L2931","documentation":"Raised by `resolve_session_id` when the special value `\"latest\"` is requested but `db.get_latest_session()` returns `None` — the state store contains no sessions at all. Since there is no session to resolve, the helper returns this error instead of a session ID. It reflects an empty database, not a lookup failure for a specific ID.","triggerScenarios":"Passing `--session latest` (or the equivalent argument) on a fresh install, after a database reset/wipe, or when session recording was disabled so no sessions were ever persisted.","commonSituations":"Running a session-dependent command on a brand-new machine; pointing ECC at an empty alternate home/data directory; after manually deleting rows from the sessions table; CI environments with no prior sessions.","solutions":["Create a session first (start an ECC session) so `latest` has a target.","Verify the data directory / profile actually contains sessions (`ecc sessions list`).","If the store was wiped intentionally, re-run the sync/indexing that creates sessions.","Use an explicit session ID from a known-good store instead of `latest`."],"exampleFix":"// before\n$ ecc graph show --session latest\nerror: No sessions found\n// after\n$ ecc sessions list            # confirm sessions exist\n$ ecc graph show --session latest","handlingStrategy":"fallback","validationCode":"# Ensure sessions exist before using 'latest'\ncount=$(ecc sessions list --json | jq 'length')\n[ \"$count\" -gt 0 ] || { echo \"no sessions; run a session first\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"match resolve_session_id(&db, \"latest\") {\n    Err(e) if e.to_string() == \"No sessions found\" => {\n        eprintln!(\"store empty — start a session before using 'latest'\");\n    }\n    Err(e) => return Err(e),\n    Ok(id) => use_session(id),\n}","preventionTips":["On fresh installs, create/record at least one session before commands that depend on 'latest'.","Verify the ECC data directory actually points at a store with sessions.","Prefer explicit session IDs in CI where the store may be empty."],"tags":["cli","database","empty","sessions"],"backgroundTag":"empty-result-set","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}