Repository navigation
fix(cli): no panic on non-UTF-8 argv or broken stdio; doctor --help is help - #574
Merged
Merged
Conversation
…elp is help The CLI read argv with std::env::args(), which panics on a word that is not UTF-8. It now reads args_os and a bad word is exit 2 naming the word. help, --version and every stderr line were written with println!/eprintln!, which panic (exit 101) when the reader has gone or the device is full; they now go through output::print and output::diagnostic, so the exit code is the outcome's own (a stdout failure stays 125, as for results). layerfs doctor --help and layerfs help doctor print doctor's usage and exit 0 instead of 2. Exit-code policy is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Usage 2, refusal 125 and success 0; stdin, --from, -- and binary stdin; a closed or broken stdout and stderr; workspace exec --stream with command exit codes 0..255, 256 and -1 against a stand-in worker. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Record the observed behaviour, including the --stream collision of a command's own exit code 2 or 125 with usage and refusal, which is left for the owner to decide. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Member
Author
|
CI note: the
|
Limit the mutable sink list to the Linux-only block. Verified on macOS: all 21 CLI tests pass; Clippy all targets with -D warnings passes. No tests deleted. Production LOC: 137229 -> 137229 (delta +0) Scope: first-party core, engine, connect, API Rust/SQL/JS and shipped Python implementation plus handwritten Python stubs. Generated stubs, tests, tools, examples, docs and third-party code excluded. Python comments and documentation strings excluded. Counter blob 31b3cc2 (tools/production_loc.py extended in #575), identical for both exact exported snapshots. Command: python3 tools/production_loc.py --root <git-archive-tree> --json. Reference absent (retired R9c; last counted 65,417 at tree 498dd19).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
layerfsCLI panicked on a non-UTF-8 argument and on a closed or full stdout/stderr (exit 101), andlayerfs doctor --helpexited 2 as a usage error. This fixes those unambiguous defects and pins the existing exit-code behaviour with tests. Documented exit codes are not changed.Refs Ephemeral-AI-Lab/layerfs-project#36 (native CLI), parent Ephemeral-AI-Lab/layerfs-project#30. Findings and decisions: https://github.com/Ephemeral-AI-Lab/layerfs-project/issues/31#issuecomment-6657201351
Changes (3 commits)
fix(cli): argv is read withargs_os; a word that is not UTF-8 is exit 2 naming the word.help,--versionand every stderr line usedprintln!/eprintln!, which panic when the reader is gone or the device is full; they now go throughoutput::print/output::diagnostic, so the exit code is the outcome's own (a stdout failure stays 125, as for results).layerfs doctor --helpandlayerfs help doctorprint doctor's usage and exit 0.layerfs doctorstill exits 0 whenever it produces a report, as documented. Production LOC +12.test(cli): usage 2 / refusal 125 / success 0; stdin,--from,--, binary stdin; closed and broken stdout and stderr;workspace exec --streamwith command exits 0..255, 256 and -1 against a stand-in worker (argv,closed_streams,exit_codes,stream_exit).docs(cli): states the behaviour above infront-ends/cli.md.Verification (Linux/WSL Ubuntu, rustc 1.85.1,
--locked --offline, each run undertimeout 120)At the final commit: new tests
argv2,closed_streams3,exit_codes5,stream_exit5 pass; the pre-existingdoctor2,store_closed1,stream1,worker2 still pass;cargo fmt --all -- --checkexit 0;clippy -p layerfs-cli --all-targets -D warningsclean;check_product_boundary.pyPASS.An independent review by a separate model had two minor points. One was real and is fixed: the tests used Linux-only
/dev/fulland the LinuxO_NONBLOCKvalue (0o4000); they now useO_NONBLOCKper platform (Linux0o4000, macOS0x4) and/dev/fullonly on Linux. The other (addcfg(unix)) was declined: LayerFS supports Linux and macOS only.Not done / risks
--streama command's own exit code 2 or 125 is indistinguishable from usage or refusal.🤖 Generated with Claude Code