{"record":{"id":"7a5628103949f57c","repo":"aaif-goose/goose","slug":"session-with-name-not-found","errorCode":null,"errorMessage":"Session with name '{}' not found.","messagePattern":"Session with name '(.+?)' not found\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/commands/session.rs","lineNumber":112,"sourceCode":"    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()\n            .filter(|session| session_regex.is_match(&session.id))\n            .collect();\n\n        if matched_sessions.is_empty() {\n            println!(\"Regex string '{}' does not match any sessions\", regex_val);\n            return Ok(());\n        }","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/commands/session.rs#L94-L130","documentation":"Thrown by `goose session remove --name <NAME>` when no session in list_all_sessions() has a name field exactly equal to the argument. Matching is exact and case-sensitive, and unnamed sessions store an empty string as their name. Because lookup goes through list_all_sessions(), hidden sessions are included — a miss means no session of any visibility carries that name.","triggerScenarios":"`goose session remove --name \"my session\"` with wrong casing, extra whitespace, or quotes; the session was renamed or never named (its name is \"\"); the name contains unicode differences from the listed value.","commonSituations":"Typing a name from memory instead of copying from `goose session list`; sessions created by older goose versions that did not persist names; names set only after a session was resumed.","solutions":["Run `goose session list` and copy the displayed name exactly (watch casing and whitespace)","Remove by ID (`--id`) or regex (`--regex`) instead","Confirm the session is stored under the current GOOSE_CONFIG_DIR/GOOSE_HOME"],"exampleFix":"# before\ngoose session remove --name MySession\n# after\ngoose session list                # shows exact name, e.g. \"my session\"\ngoose session remove --name 'my session'","handlingStrategy":"validation","validationCode":"let all = session_manager.list_all_sessions().await?;\nif !all.iter().any(|s| s.name == name_val) {\n    return Ok(());\n}\nhandle_session_remove(None, Some(name_val), None).await?;","typeGuard":"fn session_name_exists(sessions: &[Session], name: &str) -> bool {\n    sessions.iter().any(|s| s.name == name)\n}","tryCatchPattern":"if let Err(e) = handle_session_remove(None, Some(name), None).await {\n    if e.to_string().contains(\"with name\") && e.to_string().contains(\"not found\") {\n        // name already removed; continue\n    } else {\n        return Err(e);\n    }\n}","preventionTips":["Copy names verbatim from `goose session list` (matching is exact and case-sensitive)","Remember unnamed sessions have name \"\" and can only be matched by id/regex","In automation, resolve names to IDs first, then operate on IDs"],"tags":["session","cli","name-mismatch","rust"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}