Skip to content

fix(releases): combine duplicate Author type#116358

Merged
cvxluo merged 1 commit into
masterfrom
cvxluo/align-author-response-shape-with-runtime
May 29, 2026
Merged

fix(releases): combine duplicate Author type#116358
cvxluo merged 1 commit into
masterfrom
cvxluo/align-author-response-shape-with-runtime

Conversation

@cvxluo
Copy link
Copy Markdown
Contributor

@cvxluo cvxluo commented May 28, 2026

We had duplicate definitions of 'Author' across releases. Consolidate them to the type UserSerializerResponse | NonMappableUser.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label May 28, 2026
"authors": [
{
"id": 2837091,
"id": "2837091",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is the actual improvement being made - we return string types in the API, which wasn't being reflected correctly in this example. with the typing change, now this type is fixed

@cvxluo cvxluo marked this pull request as ready for review May 28, 2026 15:50
@cvxluo cvxluo requested review from a team as code owners May 28, 2026 15:50
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

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 3119b15. Configure here.

Comment thread src/sentry/api/serializers/release_details_types.py Outdated
`release_details_types.Author` was a hand-rolled duplicate of the `UserSerializerResponse | NonMappableUser` union that `get_users_for_authors()` already returns from `models/release.py`. It declared `id: int` (runtime emits `str(obj.id)`) and made 8 fields required that the serializer omits for unmatched git committers. The published `OrganizationReleaseDetailsEndpoint` schema therefore advertised a shape never produced; clients codegen'd against it break on `authors[].id` typing or on any release with an external git committer.


Move the canonical `Author` and `NonMappableUser` definitions from `models/release.py` into `release_details_types.py` (the type-only module `models/release.py` already imports `VersionInfo` from). `models/release.py`, `models/commit.py`, `models/pullrequest.py`, and `utils/committers.py` import them back from there. Single source of truth, no rename — the union is the same shape regardless of commit/PR/release context.


Importing `UserSerializerResponse` here creates a cycle via `api/serializers/types.py`. Break it by moving `SerializedAvatarFields` out of `types.py` into `users/api/serializers/user.py`, where it's primarily used as `UserSerializerResponse.avatar`. Updates the `team`/`project`/`organization` serializer import paths and bumps the existing `RetrieveReleaseDetails` example (`authors[0].id` int → str) so the now-truthful schema validates.


Co-authored-by: Claude <noreply@anthropic.com>
@cvxluo cvxluo force-pushed the cvxluo/align-author-response-shape-with-runtime branch from 3119b15 to 32c6a0f Compare May 28, 2026 16:23
hasPasswordAuth: bool
isManaged: bool
dateJoined: str
Author = UserSerializerResponse | NonMappableUser
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i chose to move this type to release_details_types since this is where the original definition was duplicated. we can move it somewhere else if needed

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 29, 2026

ID-1540

@cvxluo cvxluo merged commit 61968fc into master May 29, 2026
76 of 77 checks passed
@cvxluo cvxluo deleted the cvxluo/align-author-response-shape-with-runtime branch May 29, 2026 21:37
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