Hmbown/CodeWhale · info · anyhow::Error

Invalid input

Error message

Invalid input

What it means

When resume runs with no ID and a terminal is available, Codewhale prints a numbered session list and reads one line from stdin. The trimmed line must parse as usize; non-numeric input like 'abc' or '1a' fails with 'Invalid input'. Empty input cancels earlier with 'No session selected.'.

Source

Thrown at crates/tui/src/lib.rs:7813

        bail!("No saved sessions found.");
    }

    println!("Select a session to resume:");
    for (idx, session) in sessions.iter().enumerate() {
        println!("  {:>2}. {} ({})", idx + 1, session.title, session.id);
    }
    print!("Enter a number (or press Enter to cancel): ");
    io::stdout().flush()?;

    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let input = input.trim();
    if input.is_empty() {
        bail!("No session selected.");
    }
    let idx: usize = input
        .parse()
        .map_err(|_| anyhow::anyhow!("Invalid input"))?;
    let session = sessions
        .get(idx.saturating_sub(1))
        .ok_or_else(|| anyhow::anyhow!("Selection out of range"))?;
    Ok(session.id.clone())
}

async fn run_review(config: &Config, args: ReviewArgs) -> Result<()> {
    use crate::client::DeepSeekClient;

    let diff = collect_diff(&args)?;
    if diff.trim().is_empty() {
        bail!("No diff to review.");
    }
    validate_review_receipt_args(&args)?;
    if args.check_receipt {
        return run_review_receipt_check(&diff, &args);
    }

View on GitHub (pinned to 8880682c63)

Solutions

  1. Enter the 1-based number shown next to the session, or press Enter on an empty line to cancel
  2. In scripts, avoid the picker entirely: pass codewhale resume <SESSION_ID>
  3. When pasting, paste digits only
  4. Re-run and choose again after a typo
Defensive patterns

Strategy: validation

Validate before calling

let input = read_line_trimmed();
if !input.is_empty() && input.parse::<usize>().is_err() {
    eprintln!("enter the 1-based list number, or press Enter to cancel");
}

Type guard

fn is_valid_selection_input(input: &str) -> bool {
    let t = input.trim();
    t.is_empty() || t.parse::<usize>().is_ok()
}

Prevention

When it happens

Trigger: Typing letters, punctuation, or mixed text at the picker prompt; piping unexpected text into stdin from a script; terminals injecting escape sequences on paste.

Common situations: Muscle memory types a session name or ID prefix instead of its list number; automation feeds non-numeric stdin to an interactive command.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/cc4edb5e96c06d83. Report an issue: GitHub.