Hmbown/CodeWhale · error · anyhow::Error

Invalid input: {input}

Error message

Invalid input: {input}

What it means

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.

Source

Thrown at crates/tui/src/remote_setup/mod.rs:257

/// Print a numbered menu, read a 1-based selection from stdin, return the index.
fn prompt_choice(title: &str, options: &[String]) -> Result<usize> {
    println!();
    println!("{title}:");
    for (idx, opt) in options.iter().enumerate() {
        println!("  {:>2}. {}", idx + 1, opt);
    }
    print!("Enter a number: ");
    io::stdout().flush()?;

    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let input = input.trim();
    if input.is_empty() {
        bail!("No selection made.");
    }
    let n: usize = input
        .parse()
        .map_err(|_| anyhow::anyhow!("Invalid input: {input}"))?;
    options
        .get(n.saturating_sub(1))
        .map(|_| n - 1)
        .ok_or_else(|| anyhow::anyhow!("Selection out of range"))
}

/// Generate a runtime token from two random v4 UUIDs (OS CSPRNG via uuid),
/// matching the existing token-generation pattern in this crate.
fn generate_runtime_token() -> String {
    let a = uuid::Uuid::new_v4().simple().to_string();
    let b = uuid::Uuid::new_v4().simple().to_string();
    format!("{a}{b}")
}

#[cfg(test)]
mod tests {
    use super::*;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Enter a plain number matching a menu option
  2. Press Enter on an empty line to cancel the selection
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/tui/src/remote_setup/mod.rs:257 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/b811e621bae4e98c. Report an issue: GitHub.