Skip to content

Fix CLI panics on invalid IPs and closed output pipes - #305

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

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

Conversation

@code-inflation

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

Copy link
Copy Markdown
Owner

Invalid --ipv4 and --ipv6 values now exit 2 with a usage error, including when the address is from the wrong family. HTTP client initialization failures print a diagnostic and exit 1.

The CLI keeps the run's exit code when stdout closes in terminal, CSV, and JSON modes. Shell completions also handle a closed pipe. An unexpected stdout write error is reported once on stderr and makes an otherwise successful command exit 1.

The regression tests close the pipe before starting the CLI. The deadline tests hold back response bodies and use the test watchdog, and the HTTP fixtures use blocking reads to avoid a socket race on macOS.

All CI checks passed, including 82 tests and both Docker builds.

code-inflation and others added 4 commits September 18, 2026 21:54
…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.
@code-inflation code-inflation changed the title fix: replace CLI panics with clean errors on bad IP args and closed stdout Fix CLI panics on invalid IPs and closed output pipes Nov 22, 2026
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