Skip to content

feat(apidocs): Hide enum values and nested fields from the schema - #123968

Open
azulus wants to merge 2 commits into
masterfrom
jeremy/apidocs-omission-paths
Open

feat(apidocs): Hide enum values and nested fields from the schema#123968
azulus wants to merge 2 commits into
masterfrom
jeremy/apidocs-omission-paths

Conversation

@azulus

@azulus azulus commented Sep 9, 2026

Copy link
Copy Markdown
Member

Withholding part of the public schema only works per field today. Anything finer means hand-writing an OpenApiParameter constant beside the serializer it duplicates, and the copy drifts: /replay-count/ accepted the spans data source for 52 days before its constant mentioned it, and still documents query as optional though the validator requires it.

Keys in omit_from_public_schema become dotted paths, so a choice value or a nested field can be named the way a plain field already could. The class of the field a segment names decides what the next segment means, so data_source.discover has one reading and no second keyword is needed. Deprecation takes the same {path: reason} shape and now requires a reason. Withholding the value a field falls back to also drops the default and marks the parameter required, since a default only means anything for an optional one.

Deprecating a choice is refused rather than accepted quietly: OpenAPI can express it with oneOf branches, but drf-spectacular emits a flat enum and generators collapse those branches, so the marker would reach nobody. A path may cross into a component several shapes share only when every one of them declares it, since hiding a field from a shared shape would hide it from an endpoint that never asked.

Flat names are one-segment paths, so the 40 existing declarations are unchanged and the schema is byte-identical until something adopts a path. The second commit is the first adoption. data_source comes out exactly as before, so the deprecation those constants encoded survives being derived rather than transcribed; query becomes required, which the validator declares and test_invalid_params_query_required already asserts.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Sep 9, 2026
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch from d7a4ca7 to a1fc184 Compare September 9, 2026 22:23
@azulus azulus changed the title feat(apidocs): Address withheld schema parts by dotted path feat(apidocs): Hide enum values and nested fields from the schema Sep 9, 2026
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch 2 times, most recently from 6b7be39 to 0194020 Compare September 9, 2026 22:45
Comment thread src/sentry/apidocs/hooks.py Outdated
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch 5 times, most recently from ba99947 to 54b6584 Compare September 10, 2026 19:50
@azulus
azulus marked this pull request as ready for review September 10, 2026 19:57
@azulus
azulus requested review from a team as code owners September 10, 2026 19:57
Comment thread src/sentry/apidocs/omission_apply.py Outdated
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch from 54b6584 to 6cbfb15 Compare September 10, 2026 20:09

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread src/sentry/apidocs/hooks.py
Comment thread src/sentry/apidocs/hooks.py
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch 2 times, most recently from fdd50a9 to 6bf0381 Compare September 10, 2026 20:24
Comment thread src/sentry/apidocs/omission_apply.py Outdated
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch from 6bf0381 to 51dcadf Compare September 10, 2026 20:28

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

Comment thread src/sentry/apidocs/omission_apply.py
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch from 51dcadf to 20d87d1 Compare September 10, 2026 20:37
azulus and others added 2 commits September 10, 2026 14:08
Withholding part of the public schema only works per field today, so anything
finer means hand-writing an OpenApiParameter constant beside the serializer it
duplicates. Those drift: /replay-count/ accepted the spans data source for 52
days before its constant mentioned it.

omit_from_public_schema keys become dotted paths, and the class of the field a
segment names decides what the next segment means, so data_source.discover has
one reading. Deprecation takes the same {path: reason} shape and now needs a
reason.

Withholding a value the field falls back to marks the parameter required and
drops the default, since a default only means anything for an optional
parameter. Crossing into a component several shapes share needs every one of
them to declare it.

Flat names are one-segment paths, so the 40 existing declarations are unchanged
and the schema is byte-identical until something adopts a path.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three OpenApiParameter constants duplicated the validator the endpoint already
checks requests against, and keeping them in step was manual. It had already
failed once: spans was accepted for 52 days before a constant mentioned it.

Naming the validator in parameters= derives the documented parameters from the
fields the handler validates with. data_source is unchanged. query becomes
required, which the code enforces, and returnIds gains the default it applies.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@azulus
azulus force-pushed the jeremy/apidocs-omission-paths branch from 20d87d1 to f6fb5ca Compare September 10, 2026 21:08

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

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 f6fb5ca. Configure here.

target = _referenced_component(node)
if target is not None:
parents.setdefault(target, set()).add(owner)
return parents

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Parent check misses operation refs

Medium Severity

parents_by_component only records other schema components that hold a property $ref. It does not see a shared shape used as an operation request or response. A nested omission can therefore mutate that component and hide the field from an endpoint that never declared the path, which is the case this check is meant to block.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f6fb5ca. Configure here.

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