{"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":null,"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/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/session/manager.rs#L2338-L2374","documentation":"Returned when a session lookup by id (or the literal \"latest\") yields no record in the state store. get_session/get_latest_session return Option and the manager converts None into an anyhow error embedding the requested id. This is the canonical 'unknown session id' error of the manager API.","triggerScenarios":"Calling stop/logs/status/rebase entry points with an id that was never created, a typo'd id, after the DB was deleted, or when no sessions exist at all and 'latest' resolves to nothing.","commonSituations":"Stale session ids in scripts after wiping the .claude state DB; querying 'latest' in a fresh checkout with zero recorded sessions; passing a foreign/other-project session id.","solutions":["List existing sessions and confirm the id before acting on it","Fix the typo or use the correct session id","Create a session first (run_session) before querying it; for 'latest', ensure at least one session exists"],"exampleFix":"// before\nmanager.stop_session(\"ses_abc123\").await?;\n// after\nif manager.get_session(\"ses_abc123\").await?.is_none() {\n    eprintln!(\"session ses_abc123 not found\");\n    return Ok(());\n}\nmanager.stop_session(\"ses_abc123\").await?;","handlingStrategy":"validation","validationCode":"let known = manager.list_sessions().await?;\nif !known.iter().any(|s| s.id == id) {\n    eprintln!(\"unknown session id: {id}\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"match manager.get_session(id).await {\n    Ok(Some(s)) => /* proceed */,\n    Ok(None) => eprintln!(\"Session not found: {id}\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Resolve ids from list output, never hardcode","Handle the 'latest' sentinel only when at least one session exists","Keep the state DB intact; don't delete .claude state files between commands"],"tags":["rust","session","lookup","not-found"],"backgroundTag":"record-not-found","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"}