Skip to content

fix(search-events): Keep explicit timestamp bounds the agent drops - #2139

Draft
sentry-junior[bot] wants to merge 2 commits into
mainfrom
fix/search-errors-keep-timestamp-bounds
Draft

sentry-junior[bot] wants to merge 2 commits into
mainfrom
fix/search-errors-keep-timestamp-bounds

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

search_errors and the other runSearchEvents tools can silently run a fixed-window search over the whole period. This happens when the caller sends a structured query with timestamp:>= / timestamp:< bounds and a period.

What happens

  1. The embedded agent moves the bounds out of the query and into an absolute timeRange ({start, end}).
  2. For structured queries with an explicit period, the handler keeps period and discards the agent's timeRange (search.ts:936-938 on main).
  3. The query the handler sends no longer has the bounds. The search covers the full relative period, and nothing tells the caller.

The only guard on the agent's rewrite is isSemanticFilterDowngrade, and it only catches filters rewritten into full-text matching. It does not catch filters that were dropped.

User feedback reported this more than once: automated callers asked for fixed windows and got rolling-period totals back. In production traces, the agent returned an absolute timeRange for the requested window, and the final /events/ request still used the caller's statsPeriod.

Change

After the agent repairs a structured query, any timestamp: bounds from the caller's query that are missing from the repaired query are appended to it again. The bounds can only narrow the period, so sending them is always safe. Queries with OR/AND or parentheses are left unchanged, because a bound appended outside its group would change what it means.

The regression test sets up this case: period: "7d", the agent moves the bounds into timeRange and drops them from the query, and the request must still carry them. Without the fix, the request query has no bounds.

Out of scope: exposing start/end as tool inputs, which is #1215 / #1228. That work does not cover this path, where a period is passed alongside bounds in the query.

via @sergical.

--

View Session [Sentry]

When a structured query has timestamp:>= / timestamp:< bounds and the
caller also passes period, the embedded agent often moves the bounds
into an absolute timeRange and drops them from the query. The explicit
period then wins over that range, so the search silently runs over the
whole period instead of the requested window.

Put any dropped timestamp bounds back on the repaired query. They only
narrow the period, so they are safe to send. Grouped and boolean queries
are left alone.

Co-Authored-By: Sergiy Dybskiy <3760543+sergical@users.noreply.github.com>
@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 10, 2026 12:27pm UTC

Request Review

The grouping guard skipped restoring dropped timestamp bounds whenever
a token contained a parenthesis, including parentheses inside a quoted
value such as message:"err (timeout)". Strip quoted values before the
check so only real grouping skips the restore.

This branch was successfully deployed

1 active and 1 inactive deployments
Actions — 68cd2ca8 Deployed Nov 10, 2026 by sentry-junior[bot] via eval #1771
Preview — 68cd2ca8 Deployed Nov 10, 2026 by vercel[bot]
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.

1 participant