Skip to content

fix(grep): Handle ripgrep literal newline regex error - #1885

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/grep-literal-newline-regex
Open

sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/grep-literal-newline-regex

Conversation

@sentry

@sentry sentry Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Previously, when a user provided a regex pattern to the grep tool that contained a literal newline character (e.g., foo\nbar), ripgrep would fail with the error rg: the literal "\n" is not allowed in a regex.

This error was not specifically caught by the existing regex error handler in packages/junior/src/chat/tools/sandbox/grep.ts (line ~337), which only matched /regex parse error|error parsing regex/i. As a result, the error would fall through to a generic throw new Error(...), leading to an unhandled generic error instead of a user-friendly ToolInputError.

This change extends the regex error pattern in grep.ts to also include |is not allowed in a regex, ensuring that this specific ripgrep error is now correctly identified and converted into a ToolInputError. A new test case has been added to packages/junior/tests/unit/tools/sandbox/file-tools.test.ts to cover this scenario.

Fixes JUNIOR-7M

@sentry <feedback>: Autofix iterates on these changes
@sentry stop iterating: Autofix stops iterating on this run

This PR was automatically generated by Sentry. You can adjust this setting at any time.

@vercel

vercel Bot commented Sep 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Sep 20, 2026 10:45pm UTC

Request Review

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

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants