anomalyco / anomalyco/opencode

Search tools report malformed glob patterns as successful empty results

Open
#47,474 0 comments 0 reactions 1 assignee View on GitHub

@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: "[" }) 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
  1. Create visible.ts containing needle in a temporary directory.
  2. Invoke the built-in glob tool with { "pattern": "[" }, or grep with { "pattern": "needle", "include": "[" }.
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.