{"record":{"id":"58bced878394b189","repo":"Hmbown/CodeWhale","slug":"selection-out-of-range-58bced","errorCode":null,"errorMessage":"Selection out of range","messagePattern":"Selection out of range","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/remote_setup/mod.rs","lineNumber":261,"sourceCode":"    for (idx, opt) in options.iter().enumerate() {\n        println!(\"  {:>2}. {}\", idx + 1, opt);\n    }\n    print!(\"Enter a number: \");\n    io::stdout().flush()?;\n\n    let mut input = String::new();\n    io::stdin().read_line(&mut input)?;\n    let input = input.trim();\n    if input.is_empty() {\n        bail!(\"No selection made.\");\n    }\n    let n: usize = input\n        .parse()\n        .map_err(|_| anyhow::anyhow!(\"Invalid input: {input}\"))?;\n    options\n        .get(n.saturating_sub(1))\n        .map(|_| n - 1)\n        .ok_or_else(|| anyhow::anyhow!(\"Selection out of range\"))\n}\n\n/// Generate a runtime token from two random v4 UUIDs (OS CSPRNG via uuid),\n/// matching the existing token-generation pattern in this crate.\nfn generate_runtime_token() -> String {\n    let a = uuid::Uuid::new_v4().simple().to_string();\n    let b = uuid::Uuid::new_v4().simple().to_string();\n    format!(\"{a}{b}\")\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn generated_token_is_long_and_hex() {\n        let t = generate_runtime_token();\n        assert_eq!(t.len(), 64, \"two simple uuids = 64 hex chars\");","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/remote_setup/mod.rs#L243-L279","documentation":"prompt_choice parsed a number but options.get(n-1) found no entry — the choice exceeds the menu's 1-based range (or arithmetic underflow was saturated), so the selection is rejected.","triggerScenarios":"Thrown at crates/tui/src/remote_setup/mod.rs:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Choose a number between 1 and the last option shown","Press Enter to cancel and re-run the command"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}