fix(core): report missing glob and grep search paths - #46150
fix(core): report missing glob and grep search paths#46150GoldJohnKing wants to merge 2 commits into
Conversation
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.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
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.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Updated: PR description now follows the template, links |
Issue for this PR
Closes #45293
Type of change
What does this PR do?
When the
pathargument doesn't exist, the search tools fail silently or misleadingly:grepswallows the failedstatand 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.globpasses the missing directory as ripgrep'scwd, the spawn dies withENOENT, and the failure surfaces as a genericUnable to find files matching ...(a bareripgrep execution failedin 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 reportsNotFound, restoring the behavior of #35337. The genericmapErrorwrappers passToolFailurethrough unchanged so the path-specific message actually reaches the model. Detection is narrowed toNotFoundviaEffect.catchReason(matching #35337 and the existing convention infile-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 theNotFound-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 locationbun test tool-read ripgrep tool-question tool-edit→ 43 pass, 0 failtsgo --noEmit→ no new errors;oxlinton changed files → 0 warnings, 0 errorsScreenshots / recordings
N/A (no UI change)
Checklist