Skip to content

fix(core): surface malformed glob errors from ripgrep - #56518

Open
rudycelekli wants to merge 2 commits into
anomalyco:devfrom
rudycelekli:malformed-glob
Open

rudycelekli wants to merge 2 commits into
anomalyco:devfrom
rudycelekli:malformed-glob

Conversation

@rudycelekli

Copy link
Copy Markdown

Issue for this PR

Closes #47474

Type of change

  • Bug fix

What does this PR do?

Report ripgrep’s malformed-glob diagnostics instead of presenting an empty successful search. Keep valid no-match searches and other exit-2 partial results intact.

How did you verify your code works?

Real ripgrep and production search-tool regressions: two failures before; 29 owning tests, 34 related tests, and 290 repeated passes after. Hosted strict baseline, full Core suite, Core typecheck, and root check pass.

Source-bound qualification.

Screenshots / recordings

No visual UI code changed; behavior is asserted directly.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix works for the reported case, but as written it breaks some searches that work today.

How I checked: your two new tests fail on the base and pass with this change (29/29 in ripgrep.test.ts and tool-search.test.ts), and the packages/core typecheck passes. I also ran ripgrep by hand and with a temporary test against both branches.

Public API: unchanged.

The problem: ripgrep prints the same error parsing glob text for a bad line in a project's .gitignore or .ignore, and then keeps searching. If anything else in the same run makes ripgrep exit 2, such as a broken symlink with follow: true, the new check discards the results. With a .ignore containing [ plus a broken symlink, glob and find return [a.ts] on the base but fail with Ripgrep.Error on this branch. find backs Search.find. grep isn't affected because it passes --no-messages. Details are in the inline comment.


const code = yield* handle.exitCode
const stderr = yield* Fiber.join(stderrFiber)
if (code === 2 && stderr.includes("error parsing glob")) return yield* failure(stderr.trim())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This also matches ignore-file errors. A [ line in a project's .gitignore or .ignore makes ripgrep print rg: ./.gitignore: line 1: error parsing glob '[': ... and it keeps searching. If anything else then makes it exit 2 (for example a broken symlink with follow: true), glob and find now fail completely instead of returning their results. On the base they return the files.

Only a bad --glob value stops ripgrep, and that message has no file path: rg: error parsing glob '[': .... Could you match just that form, e.g. /^rg: error parsing glob/m, and add a test with a bad ignore file so that case keeps returning results?

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search tools report malformed glob patterns as successful empty results

1 participant