{"record":{"id":"f10d353050e6a9cb","repo":"aaif-goose/goose","slug":"invalid-selection","errorCode":null,"errorMessage":"Invalid selection","messagePattern":"Invalid selection","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/goose-cli/src/commands/session.rs","lineNumber":419,"sourceCode":"        selector = selector.item(display_text.clone(), display_text.clone(), \"\");\n    }\n\n    // Add a cancel option\n    let cancel_value = String::from(\"cancel\");\n    selector = selector.item(cancel_value, \"Cancel\", \"Cancel export\");\n\n    // Get user selection\n    let selected_display_text: String = selector.interact()?;\n\n    if selected_display_text == \"cancel\" {\n        return Err(anyhow::anyhow!(\"Export canceled\"));\n    }\n\n    // Retrieve the selected session\n    if let Some(session) = display_map.get(&selected_display_text) {\n        Ok(session.id.clone())\n    } else {\n        Err(anyhow::anyhow!(\"Invalid selection\"))\n    }\n}\n","sourceCodeStart":401,"sourceCodeEnd":422,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/crates/goose-cli/src/commands/session.rs#L401-L422","documentation":"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.","triggerScenarios":"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.","commonSituations":"Many unnamed sessions ('(no name)') producing identical display lines; exotic terminals mangling dialoguer output.","solutions":["Re-run the command and select again","Avoid the picker: pass the session ID directly to export","If reproducible, rename duplicate sessions and report the bug upstream with your session names"],"exampleFix":"# before\ngoose session export     # -> 'Invalid selection'\n# after\ngoose session list       # pick id explicitly\ngoose session export <id> -f json","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"for _ in 0..2 {\n    match prompt_interactive_session_selection(&sm).await {\n        Err(e) if e.to_string() == \"Invalid selection\" => continue, // retry the picker\n        other => return other,\n    }\n}\nanyhow::bail!(\"session picker returned an invalid selection twice\")","preventionTips":["Retry once on 'Invalid selection' — it is a defensive guard, not data corruption","Give sessions distinct names/display text to avoid picker ambiguity","Report reproducible occurrences upstream; the arm should be unreachable"],"tags":["session","interactive","unreachable-guard","export"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}