Skip to content

fix(api-docs): widen dataset enum on /events/ to include discover, errors, transactions#114787

Merged
MathurAditya724 merged 4 commits intomasterfrom
fix/events-dataset-enum-openapi
May 4, 2026
Merged

fix(api-docs): widen dataset enum on /events/ to include discover, errors, transactions#114787
MathurAditya724 merged 4 commits intomasterfrom
fix/events-dataset-enum-openapi

Conversation

@MathurAditya724
Copy link
Copy Markdown
Member

The OpenAPI spec for GET /organizations/{org}/events/ declares dataset as ["logs", "profile_functions", "spans", "uptime_results"] only. The runtime (DATASET_OPTIONS in snuba/utils.py) accepts many more values including "discover", "errors", and "transactions".

This mismatch causes the generated @sentry/api TypeScript SDK to reject these dataset values at the type level, forcing consumers (e.g. getsentry/cli) to bypass the SDK and use raw HTTP requests for any query targeting these datasets.

Changes

  • Add "discover", "errors", and "transactions" to the VisibilityParams.DATASET enum in src/sentry/apidocs/parameters.py
  • Internal, metrics-layer, and deprecated aliases (e.g. "ourlogs", "metricsEnhanced", "spansIndexed") are intentionally omitted to keep the public API surface stable

Testing

No behavior change — this only affects OpenAPI spec generation. The runtime already accepts all three values via DATASET_OPTIONS.

Context

In getsentry/cli, 4 paginated call sites in src/lib/api/ (fetchTransactionsPage, fetchSpansPage, fetchEventsPage, queryWidgetTable) use raw apiRequestToRegion instead of the SDK's queryExploreEventsInTableFormat solely because the generated types reject their dataset values. Fixing the enum here unblocks migration to the typed SDK function.

Related: getsentry/sentry-api-schema#69 (pagination wrappers — blocked on this enum for full CLI adoption).

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 4, 2026
The OpenAPI spec for GET /organizations/{org}/events/ had two gaps
blocking the generated @sentry/api TypeScript SDK from being usable
for paginated queries against legacy datasets:

1. The dataset enum only declared [logs, profile_functions, spans,
   uptime_results]. The runtime (DATASET_OPTIONS in snuba/utils.py)
   also accepts discover, errors, and transactions. Add those three
   stable values to the enum; internal/deprecated aliases are
   intentionally omitted.

2. The cursor query parameter was not declared. The endpoint uses
   self.paginate() with cursor-based pagination at runtime, but
   the @extend_schema parameters list was missing CursorQueryParam.
   Add it, following the pattern used by 42 other paginated endpoints.

Together these unblock getsentry/cli from migrating 4 raw
apiRequestToRegion call sites to the typed SDK function
(queryExploreEventsInTableFormat) and its auto-generated
pagination wrappers (getsentry/sentry-api-schema#69).
@MathurAditya724 MathurAditya724 force-pushed the fix/events-dataset-enum-openapi branch from 5ef93a6 to c298a64 Compare May 4, 2026 22:06
@MathurAditya724 MathurAditya724 marked this pull request as ready for review May 4, 2026 22:10
@MathurAditya724 MathurAditya724 requested review from a team as code owners May 4, 2026 22:10
@MathurAditya724 MathurAditya724 enabled auto-merge (squash) May 4, 2026 22:14
@MathurAditya724 MathurAditya724 merged commit fcc043b into master May 4, 2026
62 of 63 checks passed
@MathurAditya724 MathurAditya724 deleted the fix/events-dataset-enum-openapi branch May 4, 2026 22:28
cleptric pushed a commit that referenced this pull request May 5, 2026
…rors, transactions (#114787)

The OpenAPI spec for `GET /organizations/{org}/events/` declares
`dataset` as `["logs", "profile_functions", "spans", "uptime_results"]`
only. The runtime (`DATASET_OPTIONS` in `snuba/utils.py`) accepts many
more values including `"discover"`, `"errors"`, and `"transactions"`.

This mismatch causes the generated `@sentry/api` TypeScript SDK to
reject these dataset values at the type level, forcing consumers (e.g.
`getsentry/cli`) to bypass the SDK and use raw HTTP requests for any
query targeting these datasets.

## Changes

- Add `"discover"`, `"errors"`, and `"transactions"` to the
`VisibilityParams.DATASET` enum in `src/sentry/apidocs/parameters.py`
- Internal, metrics-layer, and deprecated aliases (e.g. `"ourlogs"`,
`"metricsEnhanced"`, `"spansIndexed"`) are intentionally omitted to keep
the public API surface stable

## Testing

No behavior change — this only affects OpenAPI spec generation. The
runtime already accepts all three values via `DATASET_OPTIONS`.

## Context

In `getsentry/cli`, 4 paginated call sites in `src/lib/api/`
(`fetchTransactionsPage`, `fetchSpansPage`, `fetchEventsPage`,
`queryWidgetTable`) use raw `apiRequestToRegion` instead of the SDK's
`queryExploreEventsInTableFormat` solely because the generated types
reject their `dataset` values. Fixing the enum here unblocks migration
to the typed SDK function.

Related: `getsentry/sentry-api-schema#69` (pagination wrappers — blocked
on this enum for full CLI adoption).

<!--
## Plan
1. Widen the `dataset` enum on `VisibilityParams.DATASET` in
`src/sentry/apidocs/parameters.py`
   from `["profile_functions", "logs", "spans", "uptime_results"]`
to `["discover", "errors", "logs", "profile_functions", "spans",
"transactions", "uptime_results"]`
2. Keep internal/deprecated/metrics-layer dataset aliases out of the
public enum
3. No runtime changes needed — the server already accepts these values
4. Affects both `/events/` (table) and `/events-stats/` (timeseries)
endpoints
   since both reference `VisibilityParams.DATASET`
-->
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