Skip to content

fix(apidocs): Cover Any root responses and recursive TypedDicts in the ratchet - #129984

Merged
BYK merged 1 commit into
masterfrom
fix/apidocs-response-coverage-edge-cases
Nov 4, 2026
Merged

BYK merged 1 commit into
masterfrom
fix/apidocs-response-coverage-edge-cases

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #129972. It fixes the two Cursor Bugbot findings on the response coverage ratchet.

  • Untyped root responses were skipped. A 2xx application/json schema of {} (Any) is falsy, so if schema: never checked it, and a new endpoint with an untyped root response passed. The check now walks every schema that is present (is not None), and the root is reported as untyped <METHOD> <path> <status>.
  • Recursive TypedDicts counted as untyped. Where a TypedDict repeats inside itself, _cycle_placeholder gives an object without properties. _is_untyped flagged that, and no change to the field could fix it. In the docs build (OPENAPIGENERATE), the placeholder now carries x-sentry-cycle, and the check treats it as typed. api-docs/index.ts strips the extension from the published spec, as it does x-sentry-source.

Neither case occurs in today's spec. After make build-api-docs, --prune reports 0 fixed and 0 new, so the baseline doesn't change. Neither extension appears in openapi-derefed.json.

api-docs/index.ts is the deref script for the API docs build, not app frontend code. The frontend/backend warning comment may still show up for it, as it did on #129972.

Testing

  • New unit tests: an Any root response is reported as untyped, a described recursive TypedDict has no violations, and the cycle marker is absent outside the docs build. The new tests fail against the old code (CYCLE doesn't exist there).
  • make build-api-docs, tests/apidocs/test_response_coverage.py and tests/sentry/apidocs pass (127 tests).
  • prek and mypy pass on the changed files.

via @BYK.

--

View Session in Sentry

…e ratchet

The response coverage check skipped a 2xx schema of `{}` (`Any`) because
an empty dict is falsy, so a new untyped root response passed. It also
counted the placeholder for a recursive TypedDict, an object without
properties, as untyped, which no change to the field could fix.

The check now walks every 2xx schema that is present. The placeholder
carries `x-sentry-cycle` in the docs build, which the check treats as
typed and the deref step strips like `x-sentry-source`.

Neither case occurs in today's spec, so the baseline doesn't change.

Co-Authored-By: BYK <[email protected]>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 4, 2026 22:35
@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 Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

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.

@BYK
BYK enabled auto-merge (squash) November 4, 2026 22:37
@BYK
BYK merged commit 83b9ce8 into master Nov 4, 2026
70 checks passed
@BYK
BYK deleted the fix/apidocs-response-coverage-edge-cases branch November 4, 2026 22:40
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.

1 participant