Skip to content

fix(search): error on brace/negated globs in grep fallback - #15113

Open
pcbeingused333 wants to merge 2 commits into
dagger:mainfrom
pcbeingused333:c2249-grep-globs
Open

pcbeingused333 wants to merge 2 commits into
dagger:mainfrom
pcbeingused333:c2249-grep-globs

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #15112

When rg is not installed, Workspace.search falls back to grep (searchWithGrep in engine/client/filesync.go) and passes each glob as --include=<glob>. grep uses plain fnmatch globs, so brace alternation (*.{test,spec}.ts) and negation (!*.md) are treated as literals, match nothing, and grep exits 1, which the code reports as "no matches" ([]). The caller gets an empty result with no hint that the glob was the problem.

Fix: searchWithGrep now returns an error for globs containing {/} or starting with !, asking the user to install ripgrep. Plain globs keep working as before. Translating braces to multiple --include flags was considered but negation has no grep equivalent, so a clear error keeps the behavior predictable.

This only covers syntax that grep cannot express at all. Other fallback differences remain, for example src/** matching only direct children under grep.

Test: TestSearchWithGrepUnsupportedGlobs in engine/client/filesync_test.go checks both glob forms return the error and that *.ts still matches. go test ./engine/client -run TestSearchWithGrepUnsupportedGlobs: fails before the change, passes after. Added a changie entry.


Disclosure: this change was prepared with AI assistance (Claude Code).

Workspace.search without ripgrep falls back to grep --include, which has
no brace expansion or negation, so such globs silently matched nothing.
Return an error asking to install ripgrep instead.

Signed-off-by: Alex Castillo <[email protected]>

@langri-sha langri-sha left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you 🙇 !

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Workspace.search returns nothing, without an error, when rg is missing on the client

2 participants