Skip to content

fix(cli): adopt upstream #3027 — handle non-UTF-8 argv in raw-execution fallback - #18

Merged
kylehgc merged 2 commits into
developfrom
claude/issue-12-ffc479
Jul 17, 2026
Merged

kylehgc merged 2 commits into
developfrom
claude/issue-12-ffc479

Conversation

@kylehgc

@kylehgc kylehgc commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Closes #12. Adopts rtk-ai/rtk#3027 (author: georgyia), cherry-picked preserving authorship.

What

The raw-execution fallback (run_fallback) collected argv with std::env::args(), which panics on non-UTF-8 bytes — exactly the input clap routes into the fallback as InvalidUtf8. 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 original OsString bytes to the wrapped command, and uses lossy String copies only for matching/display/tracking.

Adoption checklist (per CONTEXT.md)

  • Sync: develop already up to date with upstream/develop (no-op)
  • Flaw verified still present on develop at adoption time (std::env::args() in run_fallback, src/main.rs:1250 pre-fix)
  • Repro on Windows: not practical — Windows argv is UTF-16, not raw bytes; the regression tests are #![cfg(unix)] and run in CI
  • Cherry-pick preserving authorship (22990e9, author georgyia)
  • Quality gate: cargo fmt --all clean, cargo clippy --all-targets zero warnings, cargo test --all 2466 passed / 0 failed (Windows x64)
  • Amendments: none needed — clean cherry-pick, tempfile already a dev-dependency

🤖 Generated with Claude Code

georgyia and others added 2 commits July 17, 2026 18:20
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>
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.

Adopt upstream #3027: cli - handle non-UTF-8 argv in raw-execution fallback

2 participants