Repository navigation
fix(cli): adopt upstream #3027 — handle non-UTF-8 argv in raw-execution fallback - #18
Merged
Merged
Conversation
rtk aborted (SIGABRT, exit 134) when any argument contained bytes that are not valid UTF-8, before the wrapped command ran. Clap is not the culprit: it reads argv via args_os() and correctly reports InvalidUtf8. That error routes into run_fallback(), which then collected argv with std::env::args() — panicking on exactly the input that sent it there. The non-UTF-8 error path was itself non-UTF-8-unsafe. Read argv with args_os() and keep the OsString values for execution, so the wrapped tool receives the bytes the user typed. Lossy copies still drive matching, display and tracking, where text is all that is needed. Fixes rtk-ai#3025
… tests Amendment to the adopted upstream rtk-ai#3027 fix, per the repo test rule (rust-patterns.md: tests use expect("reason"), never bare unwrap). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #12. Adopts rtk-ai/rtk#3027 (author: georgyia), cherry-picked preserving authorship.
What
The raw-execution fallback (
run_fallback) collected argv withstd::env::args(), which panics on non-UTF-8 bytes — exactly the input clap routes into the fallback asInvalidUtf8. The never-fail safety net aborted (exit 134 release / 101 debug) on the input it exists to handle.The fix reads argv via
args_os(), forwards the originalOsStringbytes to the wrapped command, and uses lossyStringcopies only for matching/display/tracking.Adoption checklist (per CONTEXT.md)
std::env::args()inrun_fallback, src/main.rs:1250 pre-fix)#![cfg(unix)]and run in CIcargo fmt --allclean,cargo clippy --all-targetszero warnings,cargo test --all2466 passed / 0 failed (Windows x64)tempfilealready a dev-dependency🤖 Generated with Claude Code