Repository navigation
fix(ag-rledger): answer a non-UTF-8 argument with a PARSE_ERROR envelope - #2875
Merged
Merged
Conversation
`ag-rledger check $'\xff.beancount'` panicked inside std::env::args(),
before agcli ran, so the caller got a Rust panic and exit code 101 with
no JSON envelope.
main now reads std::env::args_os(). When an argument is not UTF-8 it
answers with agcli's own envelope for that case: AgentCli::run_env reads
the same process argv, finds the argument, and returns a PARSE_ERROR
envelope naming its position ("argument 2 is not valid UTF-8", exit code
2, USAGE) without dispatching anything. The envelope is printed and the
process exits through the same path as every other run.
Closes #2860
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
📊 Benchmark Results
vs base, measured in this run
A difference counts only when it clears the combined spread of the two measurements, per shape (2σ: What do these numbers mean?
|
Contributor
✅ Compatibility Test Results
What's tested
Full results available in workflow artifacts |
This was referenced Nov 6, 2026
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.
What changed
ag-rledger'smainreadsstd::env::args_os()instead ofstd::env::args(). When an argument is not valid UTF-8 it answers with agcli's own envelope for exactly that case:AgentCli::run_envreads the same process argv, finds the first argument that is not UTF-8, and returns aPARSE_ERRORenvelope naming its position, with exit code 2 (USAGE), without dispatching anything. The printing and exit are factored intoemit, so this envelope gets the same display-unsafe escaping (#2714) as every other run.Why
std::env::args()panics on a non-UTF-8 argument before agcli runs, so the caller got a Rust panic message and exit code 101 instead of a JSON envelope (#2860).ag-rledgercallscli.run(args)rather thanrun_env()because it rewrites the argv first (config aliases), so it never reached agcli's own non-UTF-8 handling. Callingrun_envonly in the non-UTF-8 case reuses agcli's envelope (message, fix, next actions, exit code) instead of re-deriving it.How to test
cargo test -p rustledger --all-features --test ag_rledger_test test_main_non_utf8_argument_is_a_parse_error_envelope: a non-UTF-8 argument as the command word, aftercheck, and after flags, each giving aPARSE_ERRORenvelope naming its position and exit code 2.Checks run locally:
cargo test -p rustledger --all-features(one failure,python_plugins_back_to_back_after_a_timeout, a 2-second plugin time budget exceeded while the machine was under heavy parallel build load; it passes on rerun and does not touchag-rledger),cargo clippy --all-features --all-targets -- -D warnings,RUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps,cargo fmt --check.Closes #2860
🤖 Generated with Claude Code