You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Malformed glob syntax is reported as a successful empty search:
glob({ pattern: "[" }) returns No files found.
grep({ pattern: "needle", include: "[" }) returns No matches found.
Both return a completed tool result with empty output. Native ripgrep rejects the same patterns with exit code 2 and error parsing glob '[': unclosed character class; missing ']'.
Expected: report the parse failure so the caller can correct the pattern. Valid searches with no matches should still succeed.
The shared adapter in packages/core/src/ripgrep.ts accepts exit code 2 unless it recognizes a regex error; glob parse errors fall through. A fix should preserve legitimate partial results.
I can contribute a focused fix and regression tests if this is not already being addressed.
Plugins
Built-in glob and grep only, exercised through the core tool test harness.
OpenCode version
V2 source at 2960c61f9c5c86f23059d9da73e632951650edc7; Bun 1.4.2, ripgrep 15.2.0.
Steps to reproduce
Create visible.ts containing needle in a temporary directory.
Invoke the built-in glob tool with { "pattern": "[" }, or grep with { "pattern": "needle", "include": "[" }.
Observe a completed tool result with empty output instead of a parse error.
Reproduced using the existing executeTool helper in packages/core/test/tool-search.test.ts with native ripgrep. Controls for a valid match, a valid empty search, and an invalid grep regex behave correctly.
Thanks for the detailed report. I reproduced this on the latest dev (35a4a68), using the core search-tool test harness with native ripgrep:
glob with pattern: "[" returns a completed result: No files found.
grep with pattern: "needle", include: "[" returns a completed result: No matches found.
Native rg --glob '[' fails with error parsing glob '[': unclosed character class; missing ']' and exits with code 2.
The controls behave correctly: a valid match, a valid empty search, and an invalid grep regex, which already comes back as an Invalid regex pattern error. In packages/core/src/ripgrep.ts, only regex parse errors are recognised on exit code 2, so glob parse errors end up as empty successes.
The script below reproduces it. Related: #56518 is an open PR for this.
Activity
opencodejr commentedon Oct 28, 2026
Thanks for the detailed report. I reproduced this on the latest
dev(35a4a68), using the core search-tool test harness with native ripgrep:globwithpattern: "["returns a completed result:No files found.grepwithpattern: "needle", include: "["returns a completed result:No matches found.rg --glob '['fails witherror parsing glob '[': unclosed character class; missing ']'and exits with code 2.The controls behave correctly: a valid match, a valid empty search, and an invalid grep regex, which already comes back as an
Invalid regex patternerror. Inpackages/core/src/ripgrep.ts, only regex parse errors are recognised on exit code 2, so glob parse errors end up as empty successes.The script below reproduces it. Related: #56518 is an open PR for this.
Reproduction script (repro.sh)
Run it:
bash repro.sh