Skip to content

ref(typing): Let newly typed helpers take a service account - #129746

Merged
gricha merged 1 commit into
ref/sa-narrow-widenfrom
ref/sa-typed-helpers
Nov 3, 2026
Merged

gricha merged 1 commit into
ref/sa-narrow-widenfrom
ref/sa-typed-helpers

Conversation

@gricha

@gricha gricha commented Nov 3, 2026

Copy link
Copy Markdown
Member

#129614 added annotations to helpers that endpoints pass request.user to. Once #129402 types request.user to include service accounts, those call sites no longer type-check, so the helpers now take a RequestPrincipal:

  • SnubaTSResultSerializer and the TimeSeriesLookup protocol only forward the caller. Sentry has no lookup implementation.
  • get_homepage_query only builds owned_by_acting_user().
  • Project.objects.get_for_user checks is_authenticated and passes the caller on to Team.objects.get_for_user, which already takes a RequestPrincipal.
  • ApiTokenSerializer only forwards the caller.

primary_email_verification_required now passes the user from require_user() to PrimaryEmailVerificationRequired instead of request.user.

No behavior change.

@gricha
gricha requested review from a team as code owners November 3, 2026 19:53
@gricha
gricha added this pull request to stack #129747 November 3, 2026 19:54
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2026
@sentry

sentry Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 780 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@gricha
gricha requested review from a team as code owners November 3, 2026 19:59
@gricha
gricha force-pushed the ref/sa-typed-helpers branch from 88bf2e1 to bb00ea7 Compare November 3, 2026 19:59
@gricha
gricha force-pushed the ref/sa-typed-helpers branch from bb00ea7 to 6e4a505 Compare November 3, 2026 20:09
@gricha
gricha force-pushed the ref/sa-typed-helpers branch from 6e4a505 to 255f531 Compare November 3, 2026 20:51
#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
gricha force-pushed the ref/sa-typed-helpers branch from 255f531 to 9ab8030 Compare November 3, 2026 21:10
@gricha
gricha merged commit 5ee4b94 into master Nov 3, 2026
97 checks passed
@gricha
gricha deleted the ref/sa-typed-helpers branch November 3, 2026 23:19
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