Skip to content

fix: find with multiple paths no longer discards results on missing path - #781

Merged
chaliy merged 1 commit into
everruns:mainfrom
achicu:achicu/fix/find-multi-path-error-handling
Mar 22, 2026
Merged

chaliy merged 1 commit into
everruns:mainfrom
achicu:achicu/fix/find-multi-path-error-handling

Conversation

@achicu

@achicu achicu commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

When find was given multiple paths and one didn't exist, it would early-return with an error, discarding all stdout accumulated from previously valid paths. Now it continues processing all paths, collecting errors separately in stderr, and sets exit code 1 only if any path failed — matching real Unix find behavior.

@achicu
achicu force-pushed the achicu/fix/find-multi-path-error-handling branch from 5451246 to 2c159de Compare March 22, 2026 17:50
@chaliy
chaliy requested a review from Copilot March 22, 2026 18:01

@chaliy chaliy left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix. The behavior now matches real Unix find — results from valid paths are preserved when other paths fail, errors go to stderr, and exit code reflects whether any path had issues.

A few notes:

CI failures are pre-existing — the cargo-vet audit failure is about unvetted jni-sys deps, unrelated to this PR.

#783

Code review:

  • collect_find_paths: The let _ = find_recursive(...) change silently swallows errors (not just missing-path errors but also e.g. permission errors). This is acceptable since collect_find_paths feeds execution_plan() which is just an optimization hint, and the real error handling lives in execute(). Worth a brief comment though — the current comment says "Ignore errors from individual paths" but doesn't clarify why it's safe to do so here vs execute().

  • execution_plan(): Removing the redundant path-existence check is correct since collect_find_paths already skips missing paths.

  • execute(): The restructured loop that collects stdout/stderr/exit_code separately is clean and correct. ControlFlow::None + ..Default::default() is fine.

  • Tests are thorough — covers both path orderings (first missing, second missing), all valid, all missing, stderr output, and exit codes. The spec test cases with ### bash_diff annotations are a nice touch.

LGTM.

@achicu
achicu force-pushed the achicu/fix/find-multi-path-error-handling branch from 2c159de to acd8117 Compare March 22, 2026 18:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Bashkit’s find builtin to better match Unix find behavior when multiple search paths are provided, ensuring results from valid paths are still emitted even if other paths are missing, while reporting missing-path errors and returning a non-zero exit status when any path fails.

Changes:

  • Update find execution to continue across multiple paths, accumulating stdout while collecting per-path errors and setting exit code to 1 if any path fails.
  • Add spec coverage for multi-path find scenarios (valid+missing, missing-first, all-valid, missing-path error message).
  • Add Rust integration tests covering mixed/missing path scenarios and stderr behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
crates/bashkit/src/builtins/ls.rs Adjusts find to aggregate output/errors across paths and updates execution-plan behavior for -exec.
crates/bashkit/tests/spec_cases/bash/find.test.sh Adds spec cases for multi-path and missing-path find behavior.
crates/bashkit/tests/find_multi_path_tests.rs Adds Rust tests validating multi-path find behavior (stdout preservation, stderr, exit codes).
Comments suppressed due to low confidence (1)

crates/bashkit/src/builtins/ls.rs:595

  • Because collect_find_paths() skips missing paths, execution_plan() may now return Some(plan) for find -exec even when some input paths are missing. The interpreter skips execute() when a plan exists (see builtins/mod.rs:485-486), so missing-path errors and exit status=1 won’t be produced in those cases. Either force execution_plan() to return None when any input path is missing/errors, or extend the plan mechanism to emit errors and enforce exit code 1.
        // Collect matched paths (collect_find_paths skips missing paths)
        let matched_paths = collect_find_paths(ctx, &search_paths, &opts).await?;
        if matched_paths.is_empty() {
            return Ok(None);
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/bashkit/src/builtins/ls.rs Resolved
@achicu

achicu commented Mar 22, 2026

Copy link
Copy Markdown
Contributor Author

sorry for the (force-pushed) seems claude decided it to go that way :)

@chaliy

chaliy commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

@achicu pls reabse on top of latest main, I added exeptions to Audit - #783

achicu pushed a commit to achicu/bashkit that referenced this pull request Mar 22, 2026
…macros 0.4.1 (everruns#783)

## Summary
- Adds `safe-to-deploy` exemptions for `jni-sys:0.3.1`, `jni-sys:0.4.1`,
and `jni-sys-macros:0.4.1`
- Fixes the `cargo vet --locked` audit failure in CI

## Context
These unvetted dependencies were causing the Audit and Check CI jobs to
fail on all PRs (including everruns#781).
@achicu
achicu force-pushed the achicu/fix/find-multi-path-error-handling branch from acd8117 to d315cce Compare March 22, 2026 18:52
@chaliy

chaliy commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

@achicu hey! Thank you for contribution! Can you pls check if Copilot comments make sense, address them if needed, and then ping me when you feel PR is ready for merge?

@achicu
achicu force-pushed the achicu/fix/find-multi-path-error-handling branch from d315cce to 83c5bb2 Compare March 22, 2026 19:43
When `find` was given multiple paths and one didn't exist, it would
early-return with an error, discarding all stdout accumulated from
previously valid paths. Now it continues processing all paths,
collecting errors separately in stderr, and sets exit code 1 only
if any path failed — matching real Unix find behavior.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@achicu
achicu force-pushed the achicu/fix/find-multi-path-error-handling branch from 83c5bb2 to 2696ba9 Compare March 22, 2026 19:45
@achicu

achicu commented Mar 22, 2026

Copy link
Copy Markdown
Contributor Author

All good, added some asserts. thank you!

@chaliy
chaliy merged commit 39e733b into everruns:main Mar 22, 2026
18 checks passed
yonas pushed a commit to yonasBSD/bashkit that referenced this pull request Mar 23, 2026
## Summary

Release v0.1.13 — patch release with 5 PRs since v0.1.12.

### Highlights

- **First contribution from @achicu!** Fixed `find` with multiple paths
silently discarding results when one path is missing (everruns#781)
- **Python/Node binding parity** — both bindings now expose the same API
surface (everruns#785)
- **Live mount/unmount** on running `Bash` instances for dynamic
filesystem composition (everruns#784)

### What's Changed

* fix(examples): exit langchain example to prevent NAPI event loop hang
(everruns#786) by @chaliy
* feat(bindings): add Python/Node binding parity (everruns#785) by @chaliy
* feat(fs): expose live mount/unmount on running Bash instance (everruns#784) by
@chaliy
* chore: add cargo-vet exemptions for jni-sys 0.3.1, 0.4.1 and
jni-sys-macros 0.4.1 (everruns#783) by @chaliy
* fix: find with multiple paths no longer discards results on missing
path (everruns#781) by @achicu
chaliy added a commit that referenced this pull request May 30, 2026
…macros 0.4.1 (#783)

## Summary
- Adds `safe-to-deploy` exemptions for `jni-sys:0.3.1`, `jni-sys:0.4.1`,
and `jni-sys-macros:0.4.1`
- Fixes the `cargo vet --locked` audit failure in CI

## Context
These unvetted dependencies were causing the Audit and Check CI jobs to
fail on all PRs (including #781).
chaliy pushed a commit that referenced this pull request May 30, 2026
…ath (#781)

When `find` was given multiple paths and one didn't exist, it would
early-return with an error, discarding all stdout accumulated from
previously valid paths. Now it continues processing all paths,
collecting errors separately in stderr, and sets exit code 1 only if any
path failed — matching real Unix find behavior.
chaliy added a commit that referenced this pull request May 30, 2026
## Summary

Release v0.1.13 — patch release with 5 PRs since v0.1.12.

### Highlights

- **First contribution from @achicu!** Fixed `find` with multiple paths
silently discarding results when one path is missing (#781)
- **Python/Node binding parity** — both bindings now expose the same API
surface (#785)
- **Live mount/unmount** on running `Bash` instances for dynamic
filesystem composition (#784)

### What's Changed

* fix(examples): exit langchain example to prevent NAPI event loop hang
(#786) by @chaliy
* feat(bindings): add Python/Node binding parity (#785) by @chaliy
* feat(fs): expose live mount/unmount on running Bash instance (#784) by
@chaliy
* chore: add cargo-vet exemptions for jni-sys 0.3.1, 0.4.1 and
jni-sys-macros 0.4.1 (#783) by @chaliy
* fix: find with multiple paths no longer discards results on missing
path (#781) by @achicu
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.

3 participants