{"record":{"id":"452cdcd85e2ae079","repo":"affaan-m/ECC","slug":"session-not-found-resolved-id","errorCode":null,"errorMessage":"Session not found: {resolved_id}","messagePattern":"Session not found: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"ecc2/src/main.rs","lineNumber":2009,"sourceCode":"            patch,\n            check,\n        }) => {\n            if all && session_id.is_some() {\n                return Err(anyhow::anyhow!(\n                    \"worktree-status does not accept a session ID when --all is set\"\n                ));\n            }\n            let reports = if all {\n                session::manager::list_sessions(&db)?\n                    .into_iter()\n                    .map(|session| build_worktree_status_report(&session, patch))\n                    .collect::<Result<Vec<_>>>()?\n            } else {\n                let id = session_id.unwrap_or_else(|| \"latest\".to_string());\n                let resolved_id = resolve_session_id(&db, &id)?;\n                let session = db\n                    .get_session(&resolved_id)?\n                    .ok_or_else(|| anyhow::anyhow!(\"Session not found: {resolved_id}\"))?;\n                vec![build_worktree_status_report(&session, patch)?]\n            };\n            if json {\n                if all {\n                    println!(\"{}\", serde_json::to_string_pretty(&reports)?);\n                } else {\n                    println!(\"{}\", serde_json::to_string_pretty(&reports[0])?);\n                }\n            } else {\n                println!(\"{}\", format_worktree_status_reports_human(&reports));\n            }\n            if check {\n                std::process::exit(worktree_status_reports_exit_code(&reports));\n            }\n        }\n        Some(Commands::WorktreeResolution {\n            session_id,\n            all,","sourceCodeStart":1991,"sourceCodeEnd":2027,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/main.rs#L1991-L2027","documentation":"`worktree-status` without `--all` resolves the session ID (defaulting to \"latest\") and loads the session from the database. If the resolved ID has no row, the command bails with this error before building the worktree status report.","triggerScenarios":"Running `ecc2 worktree-status [<session-id>]` where the ID (or the session resolved by \"latest\") is missing from the sessions table.","commonSituations":"Running the command in a fresh repo with no sessions yet (so even \"latest\" resolves to nothing); referencing a deleted session; wrong data directory or project so the ID is not in this database.","solutions":["Run the sessions list command to confirm the ID exists and copy it exactly.","Ensure at least one session exists; create/start a session first if the database is empty.","Run from the correct project directory so ecc2 opens the database containing the session.","If a custom ID was passed, check for typos or stale short IDs and re-resolve."],"exampleFix":"// before\nlet resolved_id = resolve_session_id(&db, &id)?;\nlet session = db.get_session(&resolved_id)?.ok_or_else(|| anyhow::anyhow!(\"Session not found: {resolved_id}\"))?;\n\n// after\nlet resolved_id = resolve_session_id(&db, &id)?;\nlet session = db.get_session(&resolved_id)?.ok_or_else(|| anyhow::anyhow!(\n    \"Session not found: {resolved_id}; list sessions with `ecc2 sessions`\"\n))?;","handlingStrategy":"validation","validationCode":"// shell: ensure the session exists (or default to latest only when sessions exist)\necc2 sessions --json | jq -e --arg id \"${SESSION_ID:-}\" '($id == \"\") or (map(.id) | index($id))' >/dev/null || { echo \"session $SESSION_ID not found\"; exit 1; }","typeGuard":"fn session_exists(db: &Db, id: &str) -> anyhow::Result<bool> {\n    Ok(db.get_session(id)?.is_some())\n}","tryCatchPattern":"// handle the empty-DB case explicitly before reporting not-found\nif db.get_session(&resolved_id)?.is_none() {\n    eprintln!(\"no session {resolved_id}; create one or list with `ecc2 sessions`\");\n    std::process::exit(1);\n}","preventionTips":["Create at least one session before running worktree status commands.","Verify IDs against `ecc2 sessions` output in scripts.","Run commands from the project root so the correct database is opened.","Don't hardcode session IDs in long-lived scripts; resolve 'latest' at runtime."],"tags":["sessions","worktree","database","cli"],"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"}