aaif-goose/goose · error · anyhow::Error

No identifier provided

Error message

No identifier provided

What it means

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.

Source

Thrown at crates/goose-cli/src/cli.rs:497

async fn lookup_session_id(identifier: Identifier) -> Result<String> {
    let session_manager = SessionManager::instance();

    if let Some(session_id) = identifier.session_id {
        Ok(session_id)
    } else if let Some(name) = identifier.name {
        let sessions = session_manager.list_sessions().await?;
        sessions
            .into_iter()
            .find(|s| s.name == name || s.id == name)
            .map(|s| s.id)
            .ok_or_else(|| anyhow::anyhow!("No session found with name '{}'", name))
    } else if let Some(path) = identifier.path {
        path.file_stem()
            .and_then(|s| s.to_str())
            .map(|s| s.to_string())
            .ok_or_else(|| anyhow::anyhow!("Could not extract session ID from path: {:?}", path))
    } else {
        Err(anyhow::anyhow!("No identifier provided"))
    }
}

fn parse_key_val(s: &str) -> Result<(String, String), String> {
    match s.split_once('=') {
        Some((key, value)) => Ok((key.to_string(), value.to_string())),
        None => Err(format!("invalid KEY=VALUE: {}", s)),
    }
}

#[derive(Subcommand)]
enum SessionCommand {
    #[command(about = "List all available sessions")]
    List {
        #[arg(
            short,
            long,
            help = "Output format (text, json)",

View on GitHub (pinned to 3810898a74)

Solutions

  1. Always pass one of --session-id, -n/--name, or --path to session subcommands
  2. In code, populate at least one Identifier field before calling lookup_session_id
  3. Keep the subcommands' required-argument constraints intact when editing the CLI
  4. Use --session-id for the most deterministic lookup

Example fix

# before
goose session info

# after
goose session --session-id 20250325_200615 info
Defensive patterns

Strategy: validation

Validate before calling

if identifier.session_id.is_none() && identifier.name.is_none() && identifier.path.is_none() {
    return Err(anyhow::anyhow!("pass --session-id, -n, or --path"));
}

Type guard

fn has_any_identifier(id: &Identifier) -> bool {
    id.session_id.is_some() || id.name.is_some() || id.path.is_some()
}

Prevention

When it happens

Trigger: 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.

Common situations: Embedding goose CLI structs in tools/tests; refactors that relax the clap argument requirements of session subcommands.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/bb9d37082ff3f81c. Report an issue: GitHub.