Skip to content

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

Open
mariuszs wants to merge 1 commit into
rtk-ai:developfrom
mariuszs:fix/find-passthrough-develop
Open

fix(find): fall back to raw find for unsupported flags#2160
mariuszs wants to merge 1 commit into
rtk-ai:developfrom
mariuszs:fix/find-passthrough-develop

Conversation

@mariuszs
Copy link
Copy Markdown

Problem

rtk find errors 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 forces users to reach for rtk proxy find ... | rtk proxy xargs ... to get any result, and it contradicts RTK's fallback principle: if a filter can't handle the input, run the real command unchanged rather than blocking the user.

Fix

run_from_args now detects unsupported flags up front 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),
  • returns the child exit code, propagated through the single std::process::exit in main() like every other command (run_from_args now returns Result<i32>).

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(0) instead of erroring
  • Removed the two parse_*_rejects_* tests that asserted the old blocking behavior

Gate (cargo fmt --all --check && cargo clippy --all-targets && cargo test --all) is green on develop: 1983 passed, 7 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.
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