Skip to content

fix(mcp): Keep an explicit OR from becoming AND in search_issues - #2845

Closed
sentry-junior[bot] wants to merge 2 commits into
mainfrom
fix/search-issues-keep-explicit-or
Closed

sentry-junior[bot] wants to merge 2 commits into
mainfrom
fix/search-issues-keep-explicit-or

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

A structured search_issues query with an OR that isn't a same-key in-list, such as environment:prod ("Authentication required" OR "Session unavailable"), goes to the repair agent as written. The agent prompt says OR and parentheses must be rewritten, but the only forms it knows are same-key in-lists and status:/substatus:. So it drops the OR and the parentheses, the terms get ANDed, and the search matches nothing with no note about the change. rewriteIssueQuery only sees the agent's output, which no longer has an OR.

What changes

  • search_issues runs rewriteIssueQuery on a structured query that has an OR before Seer or the agent sees it, as no-agent mode already does:
    • A same-key OR (level:error OR level:warning) becomes an in-list, and the agent gets level:[error,warning]. The result note says so.
    • Any other OR fails with the existing UserInputError that suggests in-lists or separate searches. No API or agent call is made.
  • @sentry/toolkit-core/search-query exports hasBooleanOr(query). It uses the shared grammar, so an OR inside a quoted value doesn't count.

Scope

The check only runs when looksLikeSentrySearchSyntax is true. Natural-language queries, including a lowercase "or" in prose (the grammar matches OR case-insensitively), still go to Seer or the agent unchanged. A query made only of quoted phrases joined by OR, with no field:value filter, isn't covered. Open question: should that case be rejected too?

Fixes #2844

via automation evt_905b9c478746fd9deeb853f85ad7441b · Run ID dispatch_0449b5ce4149eeb0e866727b5cbb3fab.

--

View Session [Sentry]

A structured search_issues query with an OR that isn't a same-key
in-list went to the repair agent as written. The agent can only write
in-lists, so it dropped the OR and the parentheses and ANDed the terms,
and the search matched nothing.

Rewrite or reject that OR before the agent sees it, as no-agent mode
already does: a same-key OR becomes an in-list, and any other OR fails
with a UserInputError.

Fixes #2844
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
cli Ready Ready Preview Dec 3, 2026 5:37pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 3, 2026 5:37pm UTC

Request Review

The grammar reads a lowercase "or" as the operator, so a mixed query such
as "errors or warnings is:unresolved" was rejected before the agent could
translate its prose. Count only an uppercase OR.
@vercel
vercel Bot temporarily deployed to Preview – sentry-local December 3, 2026 17:37 Inactive
@sentry-junior
sentry-junior Bot marked this pull request as ready for review December 3, 2026 17:55
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner December 3, 2026 17:55
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 3, 2026
@sentry-junior

sentry-junior Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Heads up: this PR and #2846 both fix the same bug in #2844 (an explicit OR in search_issues silently becoming AND). This PR rejects a free-text OR before the agent sees it; #2846 drops query rewriting and runs every query as written. A 4th report came in today (MCP-SERVER-H0B, details on #2844), and both PRs would fix it.

@getsentry/ocpo could you pick one? If #2846 is the direction, this one can be closed.

via automation evt_905b9c478746fd9deeb853f85ad7441b · Run ID dispatch_3a4e0a9a29fd05ec4222066d2616ab49.

This branch was successfully deployed

2 active and 1 inactive deployments
Preview – cli — f6349414 Deployed Dec 3, 2026 by vercel[bot]
Actions — f6349414 Deployed Dec 3, 2026 by sentry-junior[bot] via eval #2201
Preview – sentry-local — f6349414 Deployed Dec 3, 2026 by vercel[bot]
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.

search_issues agent turns an explicit OR into AND

1 participant