Repository navigation
fix: add is_unsupported_shape() guard before rewrite_compound() - #2903
Ev3lynx727 wants to merge 1 commit into
Conversation
Three reported issues (rtk-ai#2792, rtk-ai#2821, rtk-ai#2892) share the same root cause: rewrite_command() attempts to rewrite unsupported command shapes without early validation, producing malformed rtk invocations that fail at runtime. Add is_unsupported_shape() that rejects find/fd, rtk find/rtk fd, and unattestable constructs before expensive tokenization. find/fd are excluded entirely because rtk find/fd only support a limited flag set (-name, -iname, -type, -maxdepth); any other predicate silently produces wrong/empty results. Tests: 6 new + 2 updated. 2399 pass, 0 fail, 8 ignored.
Stores the patch from PR #2903 (rtk-ai/rtk#2903) in patches/ for local reconstruction if upstream does not merge the change. Apply with: cd <rtk-repo> && git am /path/to/patches/rtk+0001-*.patch # or: patch -p1 < /path/to/patches/rtk+0001-*.patch Relates to: Ev3lynx727/server-commands-rtk executor.ts fix that checks rtk rewrite before auto-prepending rtk prefix.
|
Thanks for the review @tapheret2 — both nits addressed:
Appreciate the independent pass! |
|
I reproduced the compound-find failure on v0.44.0 and current |
|
Thank you for tracking this down. The find part was fixed differently in #3603 (merged 2026-08-26): rtk find now follows find's own grammar and hands predicates it does not model to the real find, so find commands can keep being rewritten safely instead of being skipped. The other shapes in this PR are already left alone on develop: fd is not rewritten, an existing rtk find command comes back unchanged, and commands with backticks, $(( or <( are never rewritten. If a case here still misbehaves on the latest version, please comment or reopen with the command. |
Summary
Fixes #2902 — which is the root cause of #2792, #2821, #2892.
rewrite_command()attempts to rewrite unsupported command shapes without early validation, producing malformedrtkinvocations that fail at runtime.Changes
Adds
is_unsupported_shape()function that returns early before expensive tokenization/regex matching:rtk find/rtk fdonly support-name,-iname,-type,-maxdepth. Any other predicate (-not,-exec,-newermt,-path, etc.) silently produces wrong/empty results.$((,<(— output shape is unpredictableUser-facing impact
Before this fix, commands like
find . -name "*.log"orfd -e rswere rewritten tortk find .../rtk fd ..., which either exit with code 3 (ask) or silently produce wrong results when complex predicates are involved.After this fix, unsupported command shapes pass through to the native command unchanged — no rewrite, no malformed invocation, no silent corruption.
Changelog
Verification
cargo fmt --all— cleancargo clippy --all-targets— no new warningscargo test --all— 2399 passed, 0 failed, 8 ignored (baseline)Related
rtk findwarns on unknown predicates but then executes a DIFFERENT (broader) query — silent wrong results #2821 — Unknown predicates silently dropped