astrid-runtime/astrid · error

--target-kib requires an integer

Error message

--target-kib requires an integer

What it means

CLI argument parse error in `parse_options`: `--target-kib` was given but the next argument is missing. The flag requires a following unsigned 32-bit integer (the KiB target for the chunker profile comparison); the parser refuses to continue without it.

Source

Thrown at crates/astrid-storage-chunker-evidence/src/main.rs:168

    let mut sketch_only = false;
    let mut targets_kib = Vec::new();
    let mut output = None;
    let mut args = env::args().skip(1);
    while let Some(argument) = args.next() {
        match argument.as_str() {
            "--corpus" => corpus_specs.push(parse_path_specification("--corpus", args.next())?),
            "--version-chain" => {
                version_chain_specs.push(parse_path_specification("--version-chain", args.next())?);
            },
            "--git-history" => {
                git_history_specs.push(parse_git_specification(args.next())?);
            },
            "--no-synthetic" => include_synthetic = false,
            "--sketch-only" => sketch_only = true,
            "--target-kib" => {
                let target = args
                    .next()
                    .ok_or_else(|| anyhow::anyhow!("--target-kib requires an integer"))?
                    .parse::<u32>()
                    .context("parse --target-kib")?;
                targets_kib.push(target);
            },
            "--output" => {
                let path = args
                    .next()
                    .ok_or_else(|| anyhow::anyhow!("--output requires a path"))?;
                output = Some(PathBuf::from(path));
            },
            "-h" | "--help" => {
                print_help();
                std::process::exit(0);
            },
            unknown => bail!("unknown argument {unknown:?}; use --help"),
        }
    }
    if targets_kib.is_empty() {

View on GitHub (pinned to affd8760f4)

Solutions

  1. Pass an integer after the flag: `--target-kib 64` (repeatable for multiple targets).
  2. Check shell quoting/expansion so the value isn't dropped (e.g. quote "${TARGET}" and verify it is non-empty).
  3. Run with `--help` to see the expected `--target-kib N` syntax.

Example fix

// before
mybin --target-kib
// after
mybin --target-kib 64 --target-kib 128
Defensive patterns

Strategy: validation

Validate before calling

fn has_value_after(args: &[String], flag: &str) -> bool {
    args.iter().position(|a| a == flag)
        .map(|i| args.get(i + 1).map_or(false, |v| v.parse::<u32>().is_ok()))
        .unwrap_or(false)
}

Try / catch

let target: Option<u32> = std::env::args().nth(1).and_then(|v| v.parse().ok());
assert!(target.is_some(), "--target-kib requires an integer value");

Prevention

When it happens

Trigger: Running the chunker evidence binary as `... --target-kib` with nothing after it — e.g. `--target-kib` last on the command line, or immediately followed by another flag like `--sketch-only` (which then also triggers 'unknown argument').

Common situations: Shell line-continuation dropping the value; copy-pasting the flag without the number; script variable holding the value expanding to empty.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/84434a2cacf2c04f. Report an issue: GitHub.