Skip to content

fix(core): report missing glob and grep search paths - #46150

Open
GoldJohnKing wants to merge 2 commits into
anomalyco:devfrom
GoldJohnKing:fix/missing-search-path-errors
Open

fix(core): report missing glob and grep search paths#46150
GoldJohnKing wants to merge 2 commits into
anomalyco:devfrom
GoldJohnKing:fix/missing-search-path-errors

Conversation

@GoldJohnKing

@GoldJohnKing GoldJohnKing commented Aug 29, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #45293

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When the path argument doesn't exist, the search tools fail silently or misleadingly:

  • grep swallows the failed stat and searches the parent directory instead, so a stale or mistyped path (removed worktree, pruned cache dir) returns an empty result with no hint the path was wrong — this is grep tool silently returns empty results when the search path does not exist #45293.
  • glob passes the missing directory as ripgrep's cwd, the spawn dies with ENOENT, and the failure surfaces as a generic Unable to find files matching ... (a bare ripgrep execution failed in release builds) that looks like a ripgrep defect rather than a bad argument.

Both tools now stat the resolved path and fail with Search path does not exist: <path> when stat reports NotFound, restoring the behavior of #35337. The generic mapError wrappers pass ToolFailure through unchanged so the path-specific message actually reaches the model. Detection is narrowed to NotFound via Effect.catchReason (matching #35337 and the existing convention in file-mutation.ts / fs-util.ts), so a permission error is not misreported as a missing path. Symlink behavior is unchanged: stat still follows symlinks, and a broken symlink now reports the missing path instead of silently searching its parent.

History of the regression: reported in #35261, fixed in #35337 (merged 2026-07-04), the pre-check was dropped when the search tools were rewritten on the V2 node architecture, and the silent variant was re-reported as #45293.

Relationship to #45300: same problem, grep-only, still open. This PR also covers glob, keeps the NotFound-only narrowing from #35337, and adds happy-path controls. Happy to defer to whichever approach maintainers prefer.

How did you verify your code works?

  • bun test tool-search (packages/core) → 5/5 pass: missing dir for glob/grep, missing file for grep, plus two happy-path controls against a temp location
  • bun test tool-read ripgrep tool-question tool-edit → 43 pass, 0 fail
  • Full packages/core suite: failing set identical to a clean-checkout baseline except the three new tests now passing (remaining failures reproduce without this change)
  • tsgo --noEmit → no new errors; oxlint on changed files → 0 warnings, 0 errors

Screenshots / recordings

N/A (no UI change)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Restore the path-specific missing-path failure that was lost in the V2
tool rewrite (anomalyco#35337): when the resolved search path does not exist,
glob and grep now fail with "Search path does not exist: <path>"
instead of either silently searching the parent directory or surfacing
a generic ripgrep failure. ToolFailure errors now pass through the
generic mapError unchanged.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential duplicate found:

The current PR #46150 likely supersedes or builds upon the approach from #45300 by providing a unified solution for both tools with better error reporting.

…rors

Align with the original anomalyco#35337 implementation and existing codebase
conventions (file-mutation.ts, fs-util.ts): only a NotFound stat failure
reports "Search path does not exist"; other platform errors such as
EACCES still propagate to the generic failure wrapper instead of being
misreported as a missing path.
@github-actions github-actions Bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@GoldJohnKing

Copy link
Copy Markdown
Author

Updated: PR description now follows the template, links Closes #45293, and documents the history (#35261#35337 → lost in the V2 tool rewrite → #45293) plus the relationship to #45300 (grep-only, same problem — this PR also covers glob and keeps the NotFound-only narrowing from #35337). Happy to consolidate with #45300 if maintainers prefer a single PR.

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.

grep tool silently returns empty results when the search path does not exist

1 participant