{"record":{"id":"b811e621bae4e98c","repo":"Hmbown/CodeWhale","slug":"invalid-input-input","errorCode":null,"errorMessage":"Invalid input: {input}","messagePattern":"Invalid input: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/remote_setup/mod.rs","lineNumber":257,"sourceCode":"/// Print a numbered menu, read a 1-based selection from stdin, return the index.\nfn prompt_choice(title: &str, options: &[String]) -> Result<usize> {\n    println!();\n    println!(\"{title}:\");\n    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","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/remote_setup/mod.rs#L239-L275","documentation":"The interactive prompt_choice menu could not parse the entered text as a usize (non-numeric input), echoing the offending {input} to make the mistake obvious.","triggerScenarios":"Thrown at crates/tui/src/remote_setup/mod.rs:257 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Enter a plain number matching a menu option","Press Enter on an empty line to cancel the selection"],"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"}