anomalyco / anomalyco/opencode

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

Open Beginner friendly
#45,293 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

The grep tool silently returns an empty result set when the configured path (directory or file) does not exist, instead of reporting an error. This masks typos and misconfigured working directories: a user searching path: "src/utlis" (sic) gets zero matches with no indication that the path is wrong, and may conclude the codebase has no hits.

Expected

When the search path cannot be resolved, grep should fail with a clear ToolFailure (e.g. "path does not exist: ") so the agent can correct the argument, matching the behavior of read/glob when their targets are missing.

Actual

Grep tool returns { content: { files: [], numFiles: 0, content: "" } } for a non-existent path. The underlying FSUtil.find/realpath call degrades to an empty result, and the error is swallowed.

Environment

  • opencode version: dev
  • grep invoked with pattern + path pointing at a missing directory/file

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.

Research direction

Start at the grep tool's handling of FSUtil.find and the realpath call for the configured path. Compare how read and glob report missing targets, then make a missing file or directory produce a clear ToolFailure instead of an empty result set and verify the returned error and result behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.