anomalyco / anomalyco/opencode
Search tools report malformed glob patterns as successful empty results
@kitlangton is already working on this.
Since Sep 5, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Malformed glob syntax is reported as a successful empty search:
glob({ pattern: "[" })returnsNo files found.grep({ pattern: "needle", include: "[" })returnsNo 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.tscontainingneedlein 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.
Operating System
macOS arm64.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.