Hmbown/CodeWhale · error

No selection made.

Error message

No selection made.

What it means

`prompt_choice` reads a numeric selection from stdin; an empty line (user pressed Enter without typing, or stdin hit EOF) yields this bail. It guards against an undefined selection rather than defaulting to an option.

Solutions

  1. Enter the number of the desired option (1-based)
  2. If input cannot be interactive, run with the corresponding flags and/or --non-interactive
  3. Check that stdin is connected to a TTY when running interactive setup

Example fix

// before (piped, no input)
codewhale remote-setup < /dev/null
// after
codewhale remote-setup --non-interactive --provider anthropic --cloud aws --bridge discord
Defensive patterns

Strategy: validation

Validate before calling

# only run interactive setup with a TTY
[[ -t 0 ]] || { echo "stdin is not a TTY; use flags + --non-interactive"; exit 2; }

Try / catch

match prompt_choice(...) {
    Err(e) if e.to_string() == "No selection made." => {
        eprintln!("selection required; re-run and enter a 1-based number");
    }
    other => other?,
}

Prevention

When it happens

Trigger: Interactive `remote_setup` prompting for cloud/bridge/provider and the user submits an empty line; stdin is closed or `/dev/null` in a piped context so read_line returns empty.

Common situations: Piping the command (`codewhale remote-setup < /dev/null`) which forces an interactive prompt with no input; accidental bare Enter at the prompt.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/0004a11a170f7674. Report an issue: GitHub.

Appendix: source

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

// ---------------------------------------------------------------------------
// Prompt helpers (reuse the stdin pattern from main.rs `pick_session_id`)
// ---------------------------------------------------------------------------

/// 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}")
}

View on GitHub (pinned to 73e0f67d83)