Skip to content

cargo --version / -V falls back to raw exec (parse_failure noise) #90

Closed

Description

@thehoff

Symptom

```
$ contextcrawler cargo --version
cargo 1.95.0 (f2d3ce0bd 2026-03-21)
$ sqlite3 history.db "SELECT error_message FROM parse_failures WHERE raw_command='cargo --version' LIMIT 1;"
error: unexpected argument '--version' found
```

58 parse_failure rows for `cargo --version` over 30 days. Each call works (command runs raw), but pollutes the parse_failure table and skips telemetry.

Root cause

`Commands::Cargo` (`src/main.rs:552`) only declares `build|test|clippy|check|fmt|install` as accepted subcommands. `--version` and `-V` aren't matched → clap rejects → `run_fallback` → no TOML match → raw exec.

Fix

Cleanest: pre-clap intercept. Match `cargo --version` / `cargo -V` (and `cargo --help`, `cargo -h`) and route straight to raw passthrough with proper tracking — same pattern as the existing `grep_format_flag_present` intercept.

```rust
const PASSTHROUGH_VERSION_FLAGS: &[&str] = &["--version", "-V", "--help", "-h"];

fn cargo_passthrough_flag_present(args: &[String]) -> bool {
args.iter().any(|a| PASSTHROUGH_VERSION_FLAGS.contains(&a.as_str()))
}

// In run_cli():
let raw_args: Vec = std::env::args().skip(1).collect();
if raw_args.first().map(|s| s.as_str()) == Some("cargo")
&& cargo_passthrough_flag_present(&raw_args[1..])
{
return run_simple_passthrough("cargo", &raw_args[1..]);
}
```

Where `run_simple_passthrough` mirrors `run_grep_format_passthrough` but for a generic binary.

Bonus

The same pattern (--version/--help on a non-subcommand-aware wrapper) almost certainly affects other wrappers: `pnpm --version`, `npm --version`, `go version`, `docker --version`, `kubectl version`, etc. Worth a sweep — add a single shared `is_meta_flag(args)` helper and apply it across all wrapper intercepts.

Acceptance

  • `contextcrawler cargo --version` no longer creates a parse_failure row.
  • Same for `-V`, `--help`, `-h`.
  • A regression test in `tests/` confirms no parse_failure recorded for the four flags above on `cargo`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions