Skip to content

feat(apidocs): Describe organization response fields - #129991

Merged
BYK merged 1 commit into
masterfrom
feat/apidocs-describe-organization-fields
Nov 4, 2026
Merged

BYK merged 1 commit into
masterfrom
feat/apidocs-describe-organization-fields

Conversation

@sentry-junior

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

Copy link
Copy Markdown
Contributor

First gap-fill PR for the response coverage ratchet (#129972). It adds ApiDescription to the TypedDicts in src/sentry/api/serializers/models/organization.py and prunes 66 entries from tests/apidocs/response-coverage-baseline.txt: 65 missing descriptions and 1 untyped field.

These types back the organization details, list and summary responses (OrganizationWithProjectsAndTeams in the spec), trusted relays, onboarding tasks, and the status and links objects.

Where the wording comes from

  • The serializer code for computed fields. For example, allowSuperuserAccess is the inverse of the prevent_superuser_access flag. pendingAccessRequests counts OrganizationAccessRequests for the organization's teams. isDynamicallySampled is true when the org or any project samples below 1.
  • The existing request field docs of PUT /organizations/{org}/ for settings that the endpoint also returns, such as openMembership, attachmentsRole, storeCrashReports and the data scrubbing options. I reworded "Specify true to …" as "Whether …".
  • Where an option is read, for the Seer and code review defaults:
    • defaultSeerScannerAutomation and defaultCodingAgent follow set_default_project_seer_* and get_org_default_seer_automation_handoff.
    • autoEnableCodeReview and defaultCodeReviewTriggers follow Repository._handle_auto_enable_code_review, which only applies to GitHub.
  • The model:
    • Status IDs and labels come from OrganizationStatus.
    • Onboarding task keys and statuses come from TASK_CHOICES and STATUS_CHOICES.
    • Trusted relay created and lastModified follow the update logic in organization_details.py.

Typing

role changes from Any to str. It's set from access.role only when that isn't None, so the spec now says type: string. Serialized output doesn't change.

Left in the baseline

The code doesn't make these clear, so I didn't guess:

  • aggregatedDataConsent: it's set from the create-organization request, but nothing in sentry says what the consent covers.
  • planSampleRate and desiredSampleRate: they come from the blended rate or the target sample rate, depending on the sampling mode, and the names don't settle what a client should read them as.
  • untyped onboarding task data: its shape depends on the task.
  • untyped extraOptions{}: the type is clear (traces.spansExtractionDate: int, traces.checkSpanExtractionDate: bool), but the Sentry UI no longer reads either option, so I couldn't describe the nested fields.

Testing

  • After make build-api-docs, --prune reports 66 fixed and 0 new. Apart from descriptions, the derefed spec's only change is role gaining type: string.
  • tests/apidocs/test_response_coverage.py and tests/sentry/apidocs pass.
  • mypy and prek pass on the changed files.
  • The organization serializer and details endpoint tests need Snuba, which isn't available in my sandbox, so CI covers them. The change only adds Annotated metadata and narrows one type hint, so nothing changes at runtime.

via @BYK.

--

View Session in Sentry

Add ApiDescription to the organization serializer TypedDicts and prune
66 entries from the response coverage baseline. The wording comes from
the serializer code, the organization model and options, and the
existing request field docs.

`role` is typed `str` instead of `Any`; it's `access.role` and is only
set when that isn't None. Serialized output doesn't change.

Left in the baseline because the code doesn't make the meaning clear:
aggregatedDataConsent, planSampleRate, desiredSampleRate, and the
shapes of onboarding task `data` and `extraOptions`.

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:56
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner November 4, 2026 22:56
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 4, 2026
@BYK
BYK enabled auto-merge (squash) November 4, 2026 23:02
@BYK
BYK merged commit e41037f into master Nov 4, 2026
76 of 77 checks passed
@BYK
BYK deleted the feat/apidocs-describe-organization-fields branch November 4, 2026 23:10
BYK added a commit that referenced this pull request Nov 4, 2026
This is a response coverage gap-fill for the ratchet added in #129972,
and it follows #129991 (organization). It adds `ApiDescription`
annotations to the response TypedDicts in:

- `src/sentry/api/serializers/models/role.py`:
`BaseRoleSerializerResponse`, `OrganizationRoleSerializerResponse`,
`TeamRoleSerializerResponse`
- `src/sentry/api/serializers/models/team.py`:
`BaseTeamSerializerResponse`, `_TeamSerializerResponseOptional`, the
team SCIM responses
- `src/sentry/users/api/serializers/user.py`: `UserSerializerResponse`,
`UserSerializerResponseOptional`, `SerializedAvatarFields`, plus the
nested email, identity and authenticator types

These fix 72 entries in `tests/apidocs/response-coverage-baseline.txt`,
and this PR prunes them all. None of these files have fields left in the
baseline.

**Where the wording comes from**
- The serializer code, for example:
- `hasAccess`: member, open membership, or an organization role with
access to all teams
  - `emails` and `identities`: when they're included
  - `canReset2fa`: true only with exactly one active organization
  - `experiments`: always `{}`
- Model help texts (`User.is_managed`, `User.is_suspended`, ...).
- How the frontend uses `isRetired`: retired roles can't be assigned to
more members.
- `allowed` and `is_global` are marked as deprecated aliases. The
serializer comments call them "backward compatibility".

There are no type changes and no runtime changes. Apart from
descriptions, the generated spec matches the published
`openapi-derefed.json`. The only other difference is the timezone enum,
which comes from the local tz database.

**Testing**
- `make build-api-docs`, then `python -m
sentry.apidocs.response_coverage --prune`: 72 fixed, 0 new.
- `pytest tests/apidocs/test_response_coverage.py tests/sentry/apidocs`:
127 passed.
- mypy (pre-push) and prek pass on the changed files.

Refs getsentry/toolkit#1853

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A98eff8ed01bc8064aba01279b3ac82c3 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3A98eff8ed01bc8064aba01279b3ac82c3/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
BYK added a commit that referenced this pull request Nov 5, 2026
Next gap-fill after #129991 and #129993: add `ApiDescription`
annotations to the organization member response types and prune the
response-coverage baseline to match.

**What changes**
- `organization_member/response.py`: describes the fields of the member,
member-with-teams, member-with-roles, SCIM member and member flags
responses. The wording comes from the serializers and the existing docs.
- `core/endpoints/team_members.py` and
`core/endpoints/organization_member_team_details.py`: the `user`
override in these responses needs its own description, because the
ratchet keys it under `OrganizationMemberResponse.user`.
- `tests/apidocs/response-coverage-baseline.txt`: removes the 43 entries
this fixes.

Only descriptions change. Types and runtime behavior stay the same, and
comments that duplicated a new description are gone.

**Left in the baseline**
- `sso:invalid` and `member-limit:restricted` (member flags): the code
sets them but doesn't say what they mean to API consumers.
- `invite_link`: declared on the response type, but no serializer sets
it.

**Verification**
- I ran `make build-api-docs` and then `python -m
sentry.apidocs.response_coverage --prune`: 43 entries fixed, 0 new.
- `tests/apidocs/test_response_coverage.py` and `tests/sentry/apidocs`
pass (127 tests).
- mypy (pre-push) and ruff pass on the changed files.
- In the spec diff against prod, the only changes besides descriptions
are ones already on master.

The optional prod-vs-dev schema diff check is expected to fail, because
descriptions change.

<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A98eff8ed01bc8064aba01279b3ac82c3 -->

--

[View Session in
Sentry](https://sentry.sentry.io/explore/conversations/agent%3A98eff8ed01bc8064aba01279b3ac82c3/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>
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.

1 participant