Repository navigation
ref(typing): Let newly typed helpers take a service account - #129746
Merged
Merged
Conversation
Contributor
Sentry Snapshot Testing
|
gricha
force-pushed
the
ref/sa-typed-helpers
branch
from
November 3, 2026 19:59
88bf2e1 to
bb00ea7
Compare
gricha
force-pushed
the
ref/sa-typed-helpers
branch
from
November 3, 2026 20:09
bb00ea7 to
6e4a505
Compare
azulus
approved these changes
Nov 3, 2026
gricha
force-pushed
the
ref/sa-typed-helpers
branch
from
November 3, 2026 20:51
6e4a505 to
255f531
Compare
#129614 annotated helpers that endpoints pass request.user to. Once request.user includes ServiceAccountPrincipal, those call sites need the helpers to take a RequestPrincipal: - SnubaTSResultSerializer and the TimeSeriesLookup protocol, which only forward the caller (and no lookup is implemented in sentry). - get_homepage_query, which only builds owned_by_acting_user(). - Project.objects.get_for_user, which checks is_authenticated and passes the caller to Team.objects.get_for_user (already a RequestPrincipal). - ApiTokenSerializer, which only forwards the caller to serialize(). primary_email_verification_required now reads the email check off the user from require_user() instead of request.user. Type-only for users, agents and token callers.
gricha
force-pushed
the
ref/sa-typed-helpers
branch
from
November 3, 2026 21:10
255f531 to
9ab8030
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#129614 added annotations to helpers that endpoints pass
request.userto. Once #129402 typesrequest.userto include service accounts, those call sites no longer type-check, so the helpers now take aRequestPrincipal:SnubaTSResultSerializerand theTimeSeriesLookupprotocol only forward the caller. Sentry has no lookup implementation.get_homepage_queryonly buildsowned_by_acting_user().Project.objects.get_for_userchecksis_authenticatedand passes the caller on toTeam.objects.get_for_user, which already takes aRequestPrincipal.ApiTokenSerializeronly forwards the caller.primary_email_verification_requirednow passes the user fromrequire_user()toPrimaryEmailVerificationRequiredinstead ofrequest.user.No behavior change.