Repository navigation
ref(typing): Type request.user with service accounts everywhere in sentry - #129640
Merged
gricha merged 1 commit intoNov 4, 2026
Merged
Conversation
Contributor
Sentry Snapshot Testing
|
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 3, 2026 02:27
d821e2d to
ea701e6
Compare
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 3, 2026 02:30
ea701e6 to
c92ee41
Compare
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 3, 2026 04:03
c92ee41 to
88d673f
Compare
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 3, 2026 04:41
88d673f to
46ebf87
Compare
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 3, 2026 19:53
46ebf87 to
e7d1563
Compare
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
2 times, most recently
from
November 3, 2026 20:09
2b4a9f2 to
2c29f9d
Compare
armenzg
approved these changes
Nov 3, 2026
azulus
approved these changes
Nov 3, 2026
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
3 times, most recently
from
November 3, 2026 23:19
f63da29 to
b95e21e
Compare
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 4, 2026 00:45
b95e21e to
261db9c
Compare
…ntry Every file is off the request.user allowlist, so delete it. The mypy plugin types DRF request.user as User | AnonymousUser | ServiceAccountPrincipal in all of sentry; getsentry, which loads the plugin through a tools symlink, keeps the old type. Drops the allowlist reader, its dmypy cache handling, the allowlist ratchet test and the AGENTS.md note about the list.
gricha
force-pushed
the
ref/drop-request-user-allowlist
branch
from
November 4, 2026 01:15
261db9c to
a70aa46
Compare
gricha
added a commit
that referenced
this pull request
Nov 4, 2026
… and client config (#129630) Four one-off `request.user` reads, which drops their files from the allowlist (10 → 6). What's left is member management (#129638), data export (#129637) and `group_integration_details.py` (#129639); #129640 then deletes the allowlist. - **Agent tokens:** `resolve_minting_principal()` rejects any caller with no user (`has_user`), not just `AnonymousUser`. A service account used to resolve to a *user* principal carrying its `ServiceAccountId` and fail later; it now gets the same "Minting requires a user principal" 403 as an anonymous caller. The new assertion fails without this change: ``` E AssertionError: assert AgentPrincipal(type=<AgentPrincipalType.USER: 'user'>, id=ServiceAccountId(service_account_id=1)) is <MintingPrincipalRejection.UNSUPPORTED: 'unsupported'> ``` - **Release serialization** takes a `RequestPrincipal`. It only forwards the caller to `serialize()` and `serialize_generic_user()`, which already take one, so this is type-only. - **Notebooks** read the caller through `acting_user_id()`; same value for users and token callers. - **Client config** is built only from Django views, so its request is typed as `HttpRequest`. Type-only.
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.
Every file is off the
request.userallowlist, so this deletes it. mypy now types DRFrequest.userasUser | AnonymousUser | ServiceAccountPrincipaleverywhere in sentry.tools/mypy_helpers/request_user_allowlist.txtis gone, along with the plugin's allowlist reader, its dmypy cache handling (report_config_data) and the allowlist ratchet test.tools -> ../sentry/toolssymlink, andtest_drf_request_user_keeps_its_type_outside_sentrystill covers that.src/AGENTS.mddrops the note about the list, and theServiceAccountIdguard's docstring now says it covers code mypy doesn't check this way, such as getsentry.Full mypy passes (8475 files) and so do the plugin and principal tests (108 passed).