Skip to content

ref(conversations): Simplify conversation details endpoint#116087

Open
obostjancic wants to merge 9 commits into
masterfrom
perf/conversations-default-24h-period
Open

ref(conversations): Simplify conversation details endpoint#116087
obostjancic wants to merge 9 commits into
masterfrom
perf/conversations-default-24h-period

Conversation

@obostjancic
Copy link
Copy Markdown
Member

@obostjancic obostjancic commented May 22, 2026

When no explicit start/end is provided, the endpoint now probes progressively wider time windows to find the conversation before paginating. A cheap limit=1 query tries the requested statsPeriod (if < 30d), then 7d, 14d, and 30d and returns the first match. The paginator then fetches full pages within that resolved window.

When explicit start/end are provided, nothing changes — the endpoint validates them against the 30-day retention limit and paginates directly.

statsPeriod values >= 30d are silently ignored to prevent unbounded Snuba queries.

Refs TET-2388

obostjancic and others added 4 commits May 20, 2026 11:12
…n detail

The detail endpoint was forcing a 30-day window regardless of any statsPeriod
passed by the frontend, causing timeouts for large orgs querying all projects.

Now the endpoint respects the passed statsPeriod as the first attempt and
widens to 7d then 30d only when the conversation is not found in the narrower
window. Successful params are memoised so subsequent pagination pages skip
the failed narrow attempts. Timeouts surface as a 504 with a structured
error code and actionable message rather than a generic error.

The frontend fallback now sends no time params so the backend widening
sequence owns the full retention window logic.

Refs TET-2388
Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 22, 2026

TET-2388

@github-actions github-actions Bot added Scope: Frontend Automatically applied to PRs that change frontend components Scope: Backend Automatically applied to PRs that change backend components labels May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.58%

@obostjancic obostjancic force-pushed the perf/conversations-default-24h-period branch from 73a68b1 to 842ec72 Compare May 22, 2026 11:36
@obostjancic obostjancic marked this pull request as ready for review May 26, 2026 08:24
@obostjancic obostjancic requested review from a team as code owners May 26, 2026 08:24
Comment thread src/sentry/api/endpoints/organization_ai_conversation_details.py Outdated
Comment thread src/sentry/api/endpoints/organization_ai_conversation_details.py Outdated
Remove pagination, closures, and custom timeout handling in favor of
a single query loop with progressive time-window widening.

- Replace GenericOffsetPaginator with a direct Response({data: [...]})
- Inline widening loop in get() instead of closure-based data_fn pattern
- Add 14d widening step (7d -> 14d -> 30d)
- Accept any statsPeriod as initial step without capping at 30d
- Let TimeoutException propagate via handle_query_errors() like other
  endpoints instead of custom 504 handling
- Cap results at MAX_SPANS=1000

Co-Authored-By: Claude Sonnet 4 <[email protected]>
@obostjancic obostjancic force-pushed the perf/conversations-default-24h-period branch from 79ffe3a to 2dce353 Compare May 27, 2026 09:19
@obostjancic obostjancic changed the title perf(conversations): Progressive time-window widening for conversation detail ref(conversations): Simplify conversation details endpoint May 27, 2026
Comment thread src/sentry/api/endpoints/organization_ai_conversation_details.py
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ec373c1. Configure here.

Comment thread src/sentry/api/endpoints/organization_ai_conversation_details.py Outdated
@obostjancic obostjancic force-pushed the perf/conversations-default-24h-period branch from ec373c1 to 83e8615 Compare May 27, 2026 09:50
A user-supplied statsPeriod larger than 30d bypassed the retention
validation and produced an unbounded Snuba query. Now any statsPeriod
at or above MAX_RETENTION_DAYS is ignored and the standard 7d/14d/30d
widening steps are used instead.

Co-Authored-By: Claude Sonnet 4 <[email protected]>
@obostjancic obostjancic force-pushed the perf/conversations-default-24h-period branch from 83e8615 to 233c80a Compare May 27, 2026 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants