aaif-goose/goose · error

Invalid selection

Error message

Invalid selection

What it means

Defensive fallback after the interactive picker: the selected display string is looked up in the HashMap that the very same keys were inserted from, so under normal operation this arm is unreachable. Hitting it means the selector returned a value not produced by its items — e.g. a duplicated display text collapsing entries or a prompt/backend anomaly.

Source

Thrown at crates/goose-cli/src/commands/session.rs:419

        selector = selector.item(display_text.clone(), display_text.clone(), "");
    }

    // Add a cancel option
    let cancel_value = String::from("cancel");
    selector = selector.item(cancel_value, "Cancel", "Cancel export");

    // Get user selection
    let selected_display_text: String = selector.interact()?;

    if selected_display_text == "cancel" {
        return Err(anyhow::anyhow!("Export canceled"));
    }

    // Retrieve the selected session
    if let Some(session) = display_map.get(&selected_display_text) {
        Ok(session.id.clone())
    } else {
        Err(anyhow::anyhow!("Invalid selection"))
    }
}

View on GitHub (pinned to 3810898a74)

Solutions

  1. Re-run the command and select again
  2. Avoid the picker: pass the session ID directly to export
  3. If reproducible, rename duplicate sessions and report the bug upstream with your session names

Example fix

# before
goose session export     # -> 'Invalid selection'
# after
goose session list       # pick id explicitly
goose session export <id> -f json
Defensive patterns

Strategy: try-catch

Try / catch

for _ in 0..2 {
    match prompt_interactive_session_selection(&sm).await {
        Err(e) if e.to_string() == "Invalid selection" => continue, // retry the picker
        other => return other,
    }
}
anyhow::bail!("session picker returned an invalid selection twice")

Prevention

When it happens

Trigger: Two sessions rendering to identical display text (HashMap key collision discards one) combined with prompt edge cases; programmatic use of the selector returning an arbitrary string.

Common situations: Many unnamed sessions ('(no name)') producing identical display lines; exotic terminals mangling dialoguer output.

Related errors


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