anomalyco / anomalyco/opencode
grep tool silently returns empty results when the search path does not exist
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+pathpointing at a missing directory/file
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.
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