{"record":{"id":"758e6f8c6b1ca8ba","repo":"aaif-goose/goose","slug":"session-id-not-found","errorCode":null,"errorMessage":"Session ID '{}' not found.","messagePattern":"Session ID '(.+?)' not found\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/commands/session.rs","lineNumber":105,"sourceCode":"        .filter_map(|text| display_map.get(&text).cloned())\n        .collect();\n\n    Ok(selected_sessions)\n}\n\npub async fn handle_session_remove(\n    session_id: Option<String>,\n    name: Option<String>,\n    regex_string: Option<String>,\n) -> Result<()> {\n    let session_manager = SessionManager::instance();\n\n    let matched_sessions: Vec<Session>;\n\n    if let Some(id_val) = session_id {\n        match session_manager.get_session(&id_val, false).await {\n            Ok(session) => matched_sessions = vec![session],\n            Err(_) => return Err(anyhow::anyhow!(\"Session ID '{}' not found.\", id_val)),\n        }\n    } else if let Some(name_val) = name {\n        let all_sessions = session_manager.list_all_sessions().await?;\n        if let Some(session) = all_sessions.into_iter().find(|s| s.name == name_val) {\n            matched_sessions = vec![session];\n        } else {\n            return Err(anyhow::anyhow!(\n                \"Session with name '{}' not found.\",\n                name_val\n            ));\n        }\n    } else if let Some(regex_val) = regex_string {\n        let session_regex = Regex::new(&regex_val)\n            .with_context(|| format!(\"Invalid regex pattern '{}'\", regex_val))?;\n\n        let visible_sessions = session_manager.list_sessions().await?;\n        matched_sessions = visible_sessions\n            .into_iter()","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/commands/session.rs#L87-L123","documentation":"Thrown by `goose session remove --id <ID>` when SessionManager::get_session(id, false) returns Err, meaning no session with that ID exists in the session store. The boolean argument only controls loading messages (here false = metadata lookup only), so any Err is an existence/read failure. goose throws it because removal must resolve the ID to exactly one stored session before deleting anything.","triggerScenarios":"Running `goose session remove --id <uuid>` with a misspelled or truncated ID; the session .jsonl file was deleted from the sessions directory; GOOSE_CONFIG_DIR/GOOSE_HOME points at a different session store than the one that created the session.","commonSituations":"Copy-pasting a shortened ID from `goose session list` output; referencing a session created under another user or machine; manually cleaning ~/.config/goose/sessions; scripts that assume a session ID is still present after cleanup.","solutions":["Run `goose session list` and copy the exact, full session ID","Remove by name (`--name`) or by regex on the ID (`--regex`) instead","Verify GOOSE_CONFIG_DIR/GOOSE_HOME matches the directory the session was created in","Check the sessions directory for the <id>.jsonl file to confirm whether it still exists"],"exampleFix":"# before\ngoose session remove --id 20260101_000000_ab\n# after\ngoose session list                # copy the exact id\ngoose session remove --id 20260101_000000_abc-def0123-full","handlingStrategy":"validation","validationCode":"let ids: Vec<String> = session_manager\n    .list_all_sessions()\n    .await?\n    .into_iter()\n    .map(|s| s.id)\n    .collect();\nif !ids.contains(&session_id) {\n    return Ok(()); // nothing to remove; skip instead of erroring\n}\nhandle_session_remove(Some(session_id), None, None).await?;","typeGuard":"fn session_id_exists(ids: &[String], id: &str) -> bool {\n    ids.iter().any(|s| s == id)\n}","tryCatchPattern":"match handle_session_remove(Some(id.clone()), None, None).await {\n    Ok(_) => {}\n    Err(e) if e.to_string().contains(\"not found\") => {\n        // id already gone: treat as success, do not fail the script\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always derive IDs programmatically from `goose session list` output instead of hand-typing them","Pin GOOSE_CONFIG_DIR explicitly in scripts so the session store is deterministic","Prefer --name or --regex from the listed values when IDs may be unstable"],"tags":["session","cli","not-found","rust"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}