Repository navigation
Conversation
gricha
force-pushed
the
ref/principal-ownership-helpers
branch
from
October 31, 2026 01:29
344c697 to
a8a781b
Compare
…er() Helpers for the remaining request.user.id reads that ask whether something belongs to the caller, or hand the caller to an API that takes a user, so call sites never branch on the caller type or pass a possibly-None user id: - acting_user(principal): the user behind the caller as an object, or None. For APIs like as_user= that take a user and can't take a principal across RPC. - is_acting_user(principal, user_id): "is this mine?", False when no user is behind the caller. - owned_by_acting_user(principal, field="user_id"): a Q for "mine" (filter) or "not mine" (exclude). With no user it matches nothing, so filter(user_id=None) can't match rows that have no user. src/AGENTS.md lists them, and request.access.role for the caller's org role.
gricha
marked this pull request as ready for review
November 2, 2026 19:38
gricha
force-pushed
the
ref/principal-ownership-helpers
branch
from
November 2, 2026 19:55
a8a781b to
77f6288
Compare
Contributor
Sentry Snapshot Testing
|
skaasten
approved these changes
Nov 2, 2026
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.
Adds three helpers to
sentry.auth.principalfor the remainingrequest.user.idreads, so every call site is one line and none branches on the caller type:acting_user(principal): the user behind the caller as an object, or None. For APIs that take a user, likeas_user=, which can't take a principal across RPC.is_acting_user(principal, user_id): "is this mine?". False when no user is behind the caller, so a missing user id never matches.owned_by_acting_user(principal, field="user_id"): aQfor "mine" (filter) or "not mine" (exclude). With no user it matches nothing, sofilter(user_id=None)can't match rows that have no user.src/AGENTS.mdlists them, with a shortowned_by_acting_userexample (filter, exclude, a custom column, combining with otherQs), plusrequest.access.rolefor the caller's org role. Withacting_user_id,require_user,requires_user,get_creator_referenceandrequest.access, every remaining kind of read maps to one helper; #129401 shows them on real endpoints.