Skip to content

ref(seer-rpc): type seven RPC method returns with Pydantic#117712

Merged
azulus merged 5 commits into
masterfrom
jeremy/seer-rpc-type-common-cluster
Jun 15, 2026
Merged

ref(seer-rpc): type seven RPC method returns with Pydantic#117712
azulus merged 5 commits into
masterfrom
jeremy/seer-rpc-type-common-cluster

Conversation

@azulus

@azulus azulus commented Jun 15, 2026

Copy link
Copy Markdown
Member

Type seven Seer RPC method returns with Pydantic response models in sentry_data_models.py. These methods previously returned bare dict, leaving response shapes undocumented and unverified by mypy.

Both dispatchers (SeerRpcCallEndpoint._dispatch_to_local_method and OrganizationSeerRpcEndpoint._dispatch_to_local_method) gain a BaseModel → .dict() adapter so registered functions can return Pydantic models directly. Wire-no-op: each model's .dict() produces byte-identical JSON to the prior bare-dict return.

Phase 1.1 of `type-seer-rpc-coverage`. Seven Seer RPC methods get typed
Pydantic response models in `sentry_data_models.py`:

- `get_organization_slug` -> `OrganizationSlugResponse`
- `get_organization_project_ids` -> `OrganizationProjectIdsResponse`
- `get_organization_features` -> `OrganizationFeaturesResponse`
- `get_organization_autofix_consent` -> `OrganizationAutofixConsentResponse`
- `get_github_enterprise_integration_config` -> `GitHubEnterpriseConfigSuccessResponse | GitHubEnterpriseConfigErrorResponse`
- `send_seer_webhook` -> `SendSeerWebhookSuccessResponse | SendSeerWebhookErrorResponse`
- `check_repository_integrations_status` -> `RepositoryIntegrationsStatusResponse`

Both dispatchers (internal HMAC `SeerRpcCallEndpoint._dispatch_to_local_method`
and public bearer-token `OrganizationSeerRpcEndpoint._dispatch_to_local_method`)
now convert `BaseModel` returns to dict via `.dict()` before DRF's JSONRenderer
sees them. Wire-no-op: each model's `.dict()` produces byte-identical JSON to
the prior bare-dict return.

Audit goes 2 -> 9 / 58 typed.
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 15, 2026
@azulus azulus marked this pull request as ready for review June 15, 2026 18:45
@azulus azulus requested a review from a team as a code owner June 15, 2026 18:45
@azulus azulus changed the title ref(seer-rpc): type Common-to-Seer cluster returns with Pydantic ref(seer-rpc): type seven RPC method returns with Pydantic Jun 15, 2026
Test was using `result["projects"]` / `"projects" in result` against the
RPC method's return; with the typed Pydantic shape it accesses
`result.projects` directly.
Comment thread src/sentry/seer/endpoints/seer_rpc.py Outdated
Comment thread src/sentry/seer/sentry_data_models.py Outdated

@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 7f6f700. Configure here.

Comment thread tests/sentry/seer/agent/test_tools.py
azulus added 2 commits June 15, 2026 13:33
Pydantic v1 BaseModel.__eq__ supports comparison with plain dicts; v2
returns NotImplemented and the assertion fails. The bare `result == {...}`
pattern works today but breaks loudly on any pydantic v2 upgrade. Pre-empt
the migration by calling `.dict()` explicitly — works in both versions
and preserves the wire-no-op byte-shape assertion that's the whole point
of these checks.
@azulus azulus merged commit d60bfe5 into master Jun 15, 2026
65 checks passed
@azulus azulus deleted the jeremy/seer-rpc-type-common-cluster branch June 15, 2026 21:53
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