Skip to content

ref(typing): Narrow request.user in agent tokens, releases, notebooks and client config - #129630

Merged
gricha merged 1 commit into
ref/sa-personal-statefrom
ref/sa-oneoffs
Nov 4, 2026
Merged

gricha merged 1 commit into
ref/sa-personal-statefrom
ref/sa-oneoffs

Conversation

@gricha

@gricha gricha commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

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.

@gricha
gricha added this pull request to stack #129572 November 3, 2026 00:35
@gricha
gricha requested review from a team as code owners November 3, 2026 00:35
@gricha
gricha requested review from cvxluo and skaasten November 3, 2026 00:35
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 3, 2026
@sentry

sentry Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Sentry Snapshot Testing

Name Added Removed Changed Renamed Unchanged Skipped Status
sentry-frontend
sentry-frontend
0 0 0 0 780 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

@gricha
gricha removed this pull request from stack #129572 November 3, 2026 06:52
@gricha
gricha added this pull request to stack #129650 November 3, 2026 06:52
@gricha
gricha removed this pull request from stack #129650 November 3, 2026 19:53
@gricha
gricha added this pull request to stack #129747 November 3, 2026 19:54
@gricha
gricha requested review from a team as code owners November 3, 2026 20:02
@gricha
gricha requested review from a team as code owners November 3, 2026 20:02
@gricha
gricha force-pushed the ref/sa-oneoffs branch 2 times, most recently from 761ed1e to f5fc3be Compare November 3, 2026 20:09

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread src/sentry/seer/agent_token.py Resolved
@gricha
gricha force-pushed the ref/sa-oneoffs branch 2 times, most recently from f1378bf to 957f697 Compare November 3, 2026 21:10

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 957f697. Configure here.

Comment thread src/sentry/notebooks/endpoints/base.py Resolved
@gricha
gricha force-pushed the ref/sa-oneoffs branch 2 times, most recently from 0844d0e to 2d53d6e Compare November 4, 2026 00:44
… and client config

- resolve_minting_principal() rejects any caller with no user. 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.
- Release serialization takes a RequestPrincipal; it only forwards the
  caller to serialize() and serialize_generic_user(), which already take
  one.
- Notebook endpoints read the caller through acting_user_id().
- The client config is built only from Django views, so its request is
  typed as an HttpRequest.

Drops four files from the request.user allowlist; member management and
group_integration_details.py remain.
@gricha
gricha merged commit 952f523 into master Nov 4, 2026
99 checks passed
@gricha
gricha deleted the ref/sa-oneoffs branch November 4, 2026 03:39
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.

2 participants