Repository navigation
ref(typing): Let shared helpers take a service account - #129413
Merged
Merged
Conversation
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 1, 2026 04:24
e468a0c to
6365812
Compare
gricha
added a commit
that referenced
this pull request
Nov 1, 2026
The SeerAgentClient change from #129413: read the caller's user id with acting_user_id instead of request.user.id, so a service account gets None instead of a 403 from the ServiceAccountId guard.
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 2, 2026 19:55
6365812 to
246502d
Compare
gricha
marked this pull request as ready for review
November 2, 2026 20:06
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 2, 2026 22:08
246502d to
1e83cd4
Compare
azulus
approved these changes
Nov 2, 2026
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 2, 2026 22:36
1e83cd4 to
955b2bd
Compare
Contributor
Sentry Snapshot Testing
|
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 2, 2026 23:08
955b2bd to
965babd
Compare
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 2, 2026 23:18
965babd to
246b3c3
Compare
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 246b3c3. Configure here.
| ): | ||
| qs = qs.filter(run__user_id=int(self.user.id)) | ||
| if only_current_user and self._user_id is not None: | ||
| qs = qs.filter(run__user_id=self._user_id) |
Contributor
There was a problem hiding this comment.
Latest run skips user scoping
Medium Severity
latest_run with only_current_user now skips the user_id filter whenever _user_id is missing. A service account used to 403 on int(ServiceAccountId); it now receives the newest run for that source from any user, so it can continue someone else's Seer session.
Reviewed by Cursor Bugbot for commit 246b3c3. Configure here.
Feature gates, Seer agent access, demo/staff checks, team lookup and activity serializers now take a RequestPrincipal. Most only pass the caller to features.has() or serialize(), so this is type-only. The rest read the user id through acting_user_id()/has_user(): users, agents and token callers get the same values, and a service account gets no user instead of a ServiceAccountId.
gricha
force-pushed
the
ref/typing-shared-principal
branch
from
November 2, 2026 23:31
246b3c3 to
2164a65
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.


The helpers that endpoints hand
request.userto now take aRequestPrincipal: feature gates (get_excluded_detector_types,has_investigations_access,should_serve_action_log_activity), Seer agent access (SeerAgentClient,has_seer_agent_access_with_detail,collect_user_org_context,commit_author_for_user),is_demo_user,has_staff_option,TeamManager.get_for_userand the group activity serializers.features.has()orserialize(), or already checkhas_user(): type-only.SeerAgentClientreads the user id once throughacting_user_id()instead of sixhasattr(self.user, "id")checks.is_demo_user,collect_user_org_contextandcommit_author_for_useruseacting_user_id()/has_user().Users, agents and token callers get the same values as before. A service account now gets no user (no
user_idon its Seer runs, org context without personal teams) instead of aServiceAccountIdthat 403s when used as an int.Without it, #129402's mypy check would flag 14 more files.