{"record":{"id":"6baeb53ab8d681c8","repo":"affaan-m/ECC","slug":"session-not-found-id","errorCode":null,"errorMessage":"Session not found: {id}","messagePattern":"Session not found: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/session/manager.rs","lineNumber":2356,"sourceCode":"    }\n\n    match harness {\n        HarnessKind::Claude => Ok(PathBuf::from(\"claude\")),\n        HarnessKind::Codex => Ok(PathBuf::from(\"codex\")),\n        HarnessKind::OpenCode => Ok(PathBuf::from(\"opencode\")),\n        HarnessKind::Gemini => Ok(PathBuf::from(\"gemini\")),\n        other => anyhow::bail!(\"Unsupported agent type: {other}\"),\n    }\n}\n\nfn resolve_session(db: &StateStore, id: &str) -> Result<Session> {\n    let session = if id == \"latest\" {\n        db.get_latest_session()?\n    } else {\n        db.get_session(id)?\n    };\n\n    session.ok_or_else(|| anyhow::anyhow!(\"Session not found: {id}\"))\n}\n\nfn parse_cron_schedule(expr: &str) -> Result<CronSchedule> {\n    let trimmed = expr.trim();\n    let normalized = match trimmed.split_whitespace().count() {\n        5 => format!(\"0 {trimmed}\"),\n        6 | 7 => trimmed.to_string(),\n        fields => {\n            anyhow::bail!(\n                \"invalid cron expression `{trimmed}`: expected 5, 6, or 7 fields but found {fields}\"\n            )\n        }\n    };\n    CronSchedule::from_str(&normalized)\n        .with_context(|| format!(\"invalid cron expression `{trimmed}`\"))\n}\n\nfn next_schedule_run_at(","sourceCodeStart":2338,"sourceCodeEnd":2374,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/ecc2/src/session/manager.rs#L2338-L2374","documentation":"The resolve_session helper is the central session-ID resolver used by many public functions (merge, rebase, delete, resume, run_session, etc.). It accepts 'latest' as a special keyword to fetch the most recent session, or looks up by explicit ID. If neither yields a session, it bails. This error propagates through many call sites.","triggerScenarios":"Calling any function that uses resolve_session with an ID that does not exist in the DB, or using 'latest' when the DB has no sessions at all.","commonSituations":"Empty database on first run. Session was deleted. Wrong DB file path. Using 'latest' before any sessions have been created.","solutions":["Verify the session ID exists by listing sessions before operating on one","If using 'latest', check that at least one session exists in the DB first","Ensure cfg.db_path points to the correct state store file","Handle the not-found error gracefully in the calling layer with a user-facing message"],"exampleFix":"// before\nlet session = resolve_session(db, id)?;\n\n// after\nlet session = resolve_session(db, id)\n    .with_context(|| format!(\"Session '{id}' not found. Run `ecc2 sessions list` to see available sessions.\"))?\n;","handlingStrategy":"validation","validationCode":"fn session_exists(db: &StateStore, id: &str) -> Result<bool> {\n    if id == \"latest\" {\n        Ok(db.get_latest_session()?.is_some())\n    } else {\n        Ok(db.get_session(id)?.is_some())\n    }\n}\n\n// Before calling any resolve_session-dependent function:\nif !session_exists(db, id)? {\n    return Err(anyhow!(\"Session '{id}' not found\"));\n}","typeGuard":null,"tryCatchPattern":"match resolve_session(db, id) {\n    Ok(session) => Ok(session),\n    Err(e) if e.to_string().contains(\"Session not found\") => {\n        Err(anyhow!(\"Session '{id}' not found. Use `ecc2 sessions list` to see available IDs.\").context(e))\n    }\n    Err(e) => Err(e),\n}","preventionTips":["Always list sessions before operating on one by ID","Handle 'latest' specially when the DB may be empty","Provide user-facing messages with available session IDs when not-found occurs"],"tags":["sessions","database","not-found","resolver"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}