Skip to content

fix(tool): explain invalid regex patterns in code_search - #2069

Closed
lizhengfeng101 wants to merge 1 commit into
mainfrom
fix/code-search-regex-diagnostics
Closed

lizhengfeng101 wants to merge 1 commit into
mainfrom
fix/code-search-regex-diagnostics

Conversation

@lizhengfeng101

Copy link
Copy Markdown
Contributor

Closes #1340.

When a search mixes regex operators with literal source text, retrying the entire pattern as a fixed string changes the question. For example, the corrected FS\(_|func FS should match either alternative, not a literal pipe.

This change keeps an invalid pattern as a failed code_search call. When Git reports a -e pattern compilation error, the tool preserves the original diagnostic and exit status and suggests escaping literal metacharacters or explicitly choosing literal mode. The tool description now shows the two modes side by side. There is no automatic retry.

Verification

  • make check, make test, and make coverage passed (91.6% statement coverage).
  • Regression tests exercise both reported patterns, assert the failure and retry guidance, and check actual matches after correction. An invalid Git ref does not receive regex advice.
  • The pre-commit OCR review completed for both selected files. It noted a low-severity limitation, reproduced locally: if GIT_TRACE=1 prepends trace lines to stderr, the original Git error still reaches the model but the extra hint is omitted.

AI disclosure: OpenAI Codex CLI (gpt-6.2-astra) was used to implement and test the change and draft this PR. OpenCodeReview (gpt-6.2-astra) was used for the pre-commit review.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 2 selected item(s).

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.

code_search fails with exit 128 when a regex-mode search term contains an unbalanced parenthesis

1 participant