Skip to content

fix(find): fall back to raw find for unsupported flags#7

Open
mariuszs wants to merge 1 commit into
masterfrom
fix/find-passthrough-unsupported-flags
Open

fix(find): fall back to raw find for unsupported flags#7
mariuszs wants to merge 1 commit into
masterfrom
fix/find-passthrough-unsupported-flags

Conversation

@mariuszs

Copy link
Copy Markdown
Owner

Problem

rtk find erred out when given native find features it can't model in its structured walker — compound predicates (-not, -or, -and), actions (-exec, -execdir, -delete, -print0), and time/size/perm tests (-size, -mtime, -perm, …):

$ rtk find . -name '*.tmp' -exec rm {} \;
Error: rtk find does not support compound predicates or actions (e.g. -not, -exec). Use `find` directly.

This forced users to fall back to rtk proxy find ... | rtk proxy xargs ... to get any result, and it violates RTK's mandated fallback pattern (.claude/rules/rust-patterns.md rule #4):

Fallback pattern — If filter fails, execute raw command unchanged. Never block the user.

Fix

run_from_args now detects unsupported flags and falls back to the real find via core::runner::run_passthrough:

  • streams output unchanged (inherits stdin),
  • tracks the invocation at 0% savings (visible in rtk gain --history, like rtk proxy),
  • mirrors the child exit code (std::process::exit on non-zero).

Supported syntax (-name, -iname, -type, -maxdepth, RTK shorthand) is unaffected — it still goes through the compact filter.

Tests

  • unsupported_flags_detected / supported_flags_not_flagged_as_unsupported — flag classification
  • run_from_args_falls_back_for_unsupported_flags-not now runs the real find and returns Ok instead of erroring (was RED before the fix)
  • Removed the two parse_*_rejects_* tests that asserted the old blocking behavior

Gate: cargo fmt --all && cargo clippy --all-targets && cargo test --all — all green (2075 passed, 6 ignored, 0 clippy warnings).

rtk find errored out (anyhow::bail!) on native find features it can't
model — compound predicates (-not/-or), actions (-exec/-delete), and
time/size/perm tests — forcing the user to reach for `rtk proxy find`.

This violated RTK's mandated fallback pattern ("if filter fails, execute
raw command unchanged; never block the user"). run_from_args now detects
unsupported flags and streams the real `find` via run_passthrough,
tracking at 0% savings and mirroring the child exit code.
@mariuszs mariuszs force-pushed the fix/find-passthrough-unsupported-flags branch from ed664fa to 4226ef2 Compare May 29, 2026 18:47
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.

1 participant