Repository navigation
Conversation
gricha
force-pushed
the
ref/sa-drop-service-account-id
branch
from
November 3, 2026 20:51
bc4f222 to
126cbfc
Compare
Contributor
Sentry Snapshot Testing
|
gricha
force-pushed
the
ref/sa-drop-service-account-id
branch
4 times, most recently
from
November 4, 2026 01:15
d0b527b to
edc6cb4
Compare
gricha
force-pushed
the
ref/sa-drop-service-account-id
branch
from
November 4, 2026 03:39
edc6cb4 to
6dc283f
Compare
skaasten
approved these changes
Nov 4, 2026
gricha
marked this pull request as draft
November 4, 2026 18:04
gricha
added a commit
that referenced
this pull request
Nov 4, 2026
Service accounts can now read an event's grouping info. Callers with no user skip the stacktrace-order preference and get the default order, the same as org tokens. `EventGroupingInfoEndpoint.get` typed its request as a plain `HttpRequest`, so the `request.user` mypy check didn't cover its `request.user.id` read. A service account got 403 `user-required` from the `ServiceAccountId` guard. Once #129763 removes the guard, that becomes an `AttributeError` (500). The request is now typed as a DRF `Request` and reads `acting_user_id`. The new test on master: ``` E AssertionError: b'{"detail":{"code":"user-required","message":"This action requires a user.","extra":{}}}' E assert 403 == 200 FAILED tests/sentry/issues/endpoints/test_event_grouping_info.py::EventGroupingInfoEndpointTestCase::test_service_account ``` With the fix, the grouping info suite passes (7 tests), and the `request.user.id` ratchet drops to 123.
gricha
added a commit
that referenced
this pull request
Nov 4, 2026
…9906) `is_member_disabled_from_limit` now returns False for a caller with no user, before any membership lookup. Seat limits apply to members, and a service account isn't one. The function takes an `HttpRequest`, so the `request.user` mypy check didn't cover its `user.id` read. Sentry's own permission classes pass an `RpcUserOrganizationContext` and never reach that read. getsentry's customer details endpoint passes a DRF request with an `Organization`, which goes to `check_membership_by_id(user_id=user.id)`. A service account with `org:billing` gets 403 `user-required` there today, from the `ServiceAccountId` guard. Once #129763 removes the guard, it gets a 500. Passing `acting_user_id` instead would send `None` into a lookup that matches pending invites, so the function returns early. The new test on master: ``` E sentry.api.exceptions.UserRequired: {'detail': {'code': 'user-required', 'message': 'This action requires a user.', 'extra': {}}} FAILED tests/sentry/api/test_utils.py::IsMemberDisabledFromLimitTest::test_service_account_is_not_a_limited_member ``` With the fix, the API utils, organization permission and permissions suites pass (214 tests).
gricha
marked this pull request as ready for review
November 5, 2026 23:11
A service account on request.user no longer has an id. Reading it raises AttributeError, so code that needs a person fails loudly instead of getting a stand-in id. ServiceAccountId never equaled a user id and raised UserRequired when turned into an int. It covered code mypy didn't check while request.user was only partly typed. Now that request.user is typed everywhere in sentry, checked code can't read .id without narrowing, so the guard only turned real bugs into 403s. The APIException passthrough in RPC argument serialization existed only for this guard and is removed with it.
gricha
force-pushed
the
ref/sa-drop-service-account-id
branch
from
November 5, 2026 23:14
6dc283f to
0b94ac8
Compare
This branch has not been deployed
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.
A service account on
request.userno longer has anid. Reading it raisesAttributeError, so code that needs a person fails loudly instead of getting a stand-in id.ServiceAccountIdnever equaled a user id and raisedUserRequiredwhen turned into an int. It covered code mypy didn't check whilerequest.userwas only partly typed. With #129640 typingrequest.usereverywhere in sentry, checked code can't read.idwithout narrowing, so the guard only turned real bugs into 403s. TheAPIExceptionpassthrough in RPC argument serialization existed only for this guard and goes with it.The 82 service-account test files (~3,900 tests) pass the same with and without the guard. The replay index, the one site that used to read a service account's id, already passes no actor for service accounts.
getsentry keeps the old
request.usertype, so a service account reachingrequest.user.idthere now 500s (trial and plan-upgrade requests, Console SDK invites, docsupport). Those get fixed one at a time; billing writes are already refused by getsentry#22906.