Skip to content

feat(explore): Accept crossEvents param on saved queries#113286

Open
nsdeschenes wants to merge 6 commits intomasterfrom
nd/EXP-667/chore-explore-allow-saving-of-cross-events
Open

feat(explore): Accept crossEvents param on saved queries#113286
nsdeschenes wants to merge 6 commits intomasterfrom
nd/EXP-667/chore-explore-allow-saving-of-cross-events

Conversation

@nsdeschenes
Copy link
Copy Markdown
Contributor

@nsdeschenes nsdeschenes commented Apr 17, 2026

The goal of this PR is to enable users to save their cross-event queries, so they can easily view them over time.

When accepting an optional cross-event query, we also want to ensure that we follow the same limitations we have set on the FE. This means we limit them to two cross event queries either for spans or logs, as well as limiting the period selection window to seven days.

As well, this PR includes POST and PUT request tests for the initial saving of a query, and updating of a query that contains cross event queries.

Closes EXP-667

Add an optional top-level crossEvents array to the Explore saved queries
POST/PUT serializer, and echo it back in GET responses. Each entry is a
{query, type} pair where type is limited to spans or logs.

Server-side validation enforces a max of 2 entries, the type whitelist,
and a 7-day range cap when crossEvents is present (matching the frontend
MAX_CROSS_EVENT_QUERIES and MAX_PERIOD_FOR_CROSS_EVENTS constants). The
field lives inside the existing query JSONField, so no model or
migration changes are required.

Refs EXP-667
Add happy-path, absence, over-limit, invalid-type, and >7d-range cases
to the POST endpoint tests.

Refs EXP-667
Add cases for adding, clearing, and rejecting invalid crossEvents on
the detail endpoint PUT handler.

Refs EXP-667
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 17, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 17, 2026
Comment thread src/sentry/explore/endpoints/serializers.py Outdated
sync_prebuilt_queries instantiates ExploreSavedQuerySerializer with a
context that only contains project_id, so a prebuilt query with
crossEvents would raise KeyError when the validator dereferenced
params[\"start\"] / params[\"end\"]. Only run the 7-day range check when
both are present; the endpoint path still passes them via
get_filter_params.

Co-Authored-By: Claude <noreply@anthropic.com>
@nsdeschenes nsdeschenes marked this pull request as ready for review April 17, 2026 14:49
@nsdeschenes nsdeschenes requested review from a team as code owners April 17, 2026 14:49
Comment thread tests/sentry/explore/endpoints/test_explore_saved_queries.py
Copy link
Copy Markdown
Contributor

@manessaraj manessaraj left a comment

Choose a reason for hiding this comment

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

Looks good to me

Co-Authored-By: Claude <noreply@anthropic.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants