Skip to content

ref(typing): Let shared helpers take a service account - #129413

Draft
gricha wants to merge 1 commit into
ref/typing-serialize-principalfrom
ref/typing-shared-principal
Draft

gricha wants to merge 1 commit into
ref/typing-serialize-principalfrom
ref/typing-shared-principal

Conversation

@gricha

@gricha gricha commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

The helpers that endpoints hand request.user to now take a RequestPrincipal: 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_user and the group activity serializers.

  • Most only pass the caller on to features.has() or serialize(), or already check has_user(): type-only.
  • SeerAgentClient reads the user id once through acting_user_id() instead of six hasattr(self.user, "id") checks. is_demo_user, collect_user_org_context and commit_author_for_user use acting_user_id() / has_user().

Users, agents and token callers get the same values as before. A service account now gets no user (no user_id on its Seer runs, org context without personal teams) instead of a ServiceAccountId that 403s when used as an int.

Without it, #129402's mypy check would flag 14 more files.

@gricha
gricha added this pull request to stack #129364 October 31, 2026 01:30
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 31, 2026
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
gricha removed this pull request from stack #129364 November 1, 2026 04:24
@gricha
gricha force-pushed the ref/typing-shared-principal branch from e468a0c to 6365812 Compare November 1, 2026 04:24
@gricha
gricha added this pull request to stack #129440 November 1, 2026 04:24
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.

This branch has not been deployed

No deployments
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.

1 participant