{"record":{"id":"bb9d37082ff3f81c","repo":"aaif-goose/goose","slug":"no-identifier-provided","errorCode":null,"errorMessage":"No identifier provided","messagePattern":"No identifier provided","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/cli.rs","lineNumber":497,"sourceCode":"async fn lookup_session_id(identifier: Identifier) -> Result<String> {\n    let session_manager = SessionManager::instance();\n\n    if let Some(session_id) = identifier.session_id {\n        Ok(session_id)\n    } else if let Some(name) = identifier.name {\n        let sessions = session_manager.list_sessions().await?;\n        sessions\n            .into_iter()\n            .find(|s| s.name == name || s.id == name)\n            .map(|s| s.id)\n            .ok_or_else(|| anyhow::anyhow!(\"No session found with name '{}'\", name))\n    } else if let Some(path) = identifier.path {\n        path.file_stem()\n            .and_then(|s| s.to_str())\n            .map(|s| s.to_string())\n            .ok_or_else(|| anyhow::anyhow!(\"Could not extract session ID from path: {:?}\", path))\n    } else {\n        Err(anyhow::anyhow!(\"No identifier provided\"))\n    }\n}\n\nfn parse_key_val(s: &str) -> Result<(String, String), String> {\n    match s.split_once('=') {\n        Some((key, value)) => Ok((key.to_string(), value.to_string())),\n        None => Err(format!(\"invalid KEY=VALUE: {}\", s)),\n    }\n}\n\n#[derive(Subcommand)]\nenum SessionCommand {\n    #[command(about = \"List all available sessions\")]\n    List {\n        #[arg(\n            short,\n            long,\n            help = \"Output format (text, json)\",","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/cli.rs#L479-L515","documentation":"anyhow error from lookup_session_id (crates/goose-cli/src/cli.rs) when the Identifier has no session_id, name, or path set. lookup_session_id (unlike the chat bootstrap path) has no 'default to most recent session' fallback, so a session subcommand reached it with an empty identifier — normally prevented by the subcommand's own argument requirements, so this is a guard for programmatic/future callers.","triggerScenarios":"Constructing Identifier::default() and calling lookup_session_id directly; a session subcommand invoked with no identifier options in a code path that does not pre-validate.","commonSituations":"Embedding goose CLI structs in tools/tests; refactors that relax the clap argument requirements of session subcommands.","solutions":["Always pass one of --session-id, -n/--name, or --path to session subcommands","In code, populate at least one Identifier field before calling lookup_session_id","Keep the subcommands' required-argument constraints intact when editing the CLI","Use --session-id for the most deterministic lookup"],"exampleFix":"# before\ngoose session info\n\n# after\ngoose session --session-id 20250325_200615 info","handlingStrategy":"validation","validationCode":"if identifier.session_id.is_none() && identifier.name.is_none() && identifier.path.is_none() {\n    return Err(anyhow::anyhow!(\"pass --session-id, -n, or --path\"));\n}","typeGuard":"fn has_any_identifier(id: &Identifier) -> bool {\n    id.session_id.is_some() || id.name.is_some() || id.path.is_some()\n}","tryCatchPattern":null,"preventionTips":["Always pass one identifier flag to session subcommands","In code, populate an Identifier field before lookup","Keep subcommand argument requirements strict"],"tags":["cli","session","identifier","unreachable-code"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}