Skip to content

fix: replace CLI panics with clean errors on bad IP args and closed stdout - #305

Draft
code-inflation wants to merge 2 commits into
masterfrom
fix/p1-cli-robustness
Draft

code-inflation wants to merge 2 commits into
masterfrom
fix/p1-cli-robustness

Conversation

@code-inflation

@code-inflation code-inflation commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Fixes two ways the CLI could crash with exit code 101: invalid --ipv4/--ipv6
values panicked at client construction instead of failing argument validation,
and any write to a closed stdout panicked (e.g. cfspeedtest -o json | jq with
jq exiting early). Invalid addresses now get a clap usage error and exit 2,
rejecting an IPv6 value for --ipv4 and vice versa; broken pipes are tolerated
silently and the run finishes with its normal exit code; unexpected stdout write
errors are reported once on stderr. Completion scripts are buffered in memory
because clap_complete panics on write errors. No new flags; --ipv4/--ipv6
still accept the same values and the library API is unchanged.

…tdout

- Validate --ipv4/--ipv6 values with clap value parsers so invalid
  addresses produce a usage error with exit code 2 instead of a panic
  (previously exit 101), and collapse the three duplicate client
  construction branches in main.rs into one.
- Route all stdout writes through new tolerant helpers (src/stdout.rs):
  a broken pipe (e.g. the consumer of 'cfspeedtest -o json | jq' exiting
  early) is now tolerated silently instead of panicking with exit 101;
  unexpected stdout write errors are reported once on stderr. Completion
  scripts are buffered in memory because clap_complete panics on write
  errors.
- Add regression tests for both behaviors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant