Skip to content

fix(api): Validate selected_columns in OrganizationEventsEndpoint for RPC datasets#120607

Draft
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/api-org-events-empty-columns
Draft

fix(api): Validate selected_columns in OrganizationEventsEndpoint for RPC datasets#120607
sentry[bot] wants to merge 1 commit into
masterfrom
seer/fix/api-org-events-empty-columns

Conversation

@sentry

@sentry sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The OrganizationEventsEndpoint was encountering SnubaRPCError: code: 400 when querying RPC-backed datasets (like OurLogs or spans) if the client did not provide any field parameters, resulting in an empty selected_columns list. Snuba's RPC layer would reject these requests with the message "At least one column must be specified in the request".

This fix introduces an explicit validation check within the flex_time_data_fn and data_fn functions inside paginator_factory in src/sentry/api/endpoints/organization_events.py. Before calling scoped_dataset.run_table_query for RPC datasets, it now verifies that self.get_field_list(organization, request) returns a non-empty list. If no columns are selected, an InvalidSearchQuery("No columns selected") exception is raised. This aligns the behavior with discover.query, providing a more informative and earlier error response to the client.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes SENTRY-5RGR

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 24, 2026
@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Backend Test Failures

Failures on ce7eb0b in this run:

tests/snuba/api/endpoints/test_organization_events_trace_metrics.py::OrganizationEventsTraceMetricsEndpointTest::test_count_if_with_quoteslog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/api/endpoints/test_organization_events_trace_metrics.py:807: in test_count_if_with_quotes
    assert response.status_code == 200, response.content
E   AssertionError: b'{"detail":"No columns selected"}'
E   assert 400 == 200
E    +  where 400 = <Response status_code=400, "application/json">.status_code
tests/snuba/api/endpoints/test_organization_events_span_indexed.py::OrganizationEventsSpansEndpointTest::test_count_if_span_status_equation_quotedlog
[gw1] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/api/endpoints/test_organization_events_span_indexed.py:6450: in test_count_if_span_status_equation_quoted
    assert response.status_code == 200, response.content
E   AssertionError: b'{"detail":"No columns selected"}'
E   assert 400 == 200
E    +  where 400 = <Response status_code=400, "application/json">.status_code
tests/snuba/api/endpoints/test_organization_events_trace_metrics.py::OrganizationEventsTraceMetricsEndpointTest::test_count_if_in_equationlog
[gw0] linux -- Python 3.13.1 /home/runner/work/sentry/sentry/.venv/bin/python3
tests/snuba/api/endpoints/test_organization_events_trace_metrics.py:841: in test_count_if_in_equation
    assert response.status_code == 200, response.content
E   AssertionError: b'{"detail":"No columns selected"}'
E   assert 400 == 200
E    +  where 400 = <Response status_code=400, "application/json">.status_code

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.

0 participants