Skip to content

ref(auth): Remove legacy viewer context APIs (final cleanup) - #128112

Merged
gricha merged 3 commits into
masterfrom
ref/viewer-context-v2-only
Oct 23, 2026
Merged

gricha merged 3 commits into
masterfrom
ref/viewer-context-v2-only

Conversation

@gricha

@gricha gricha commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

7/7 — FINAL CLEANUP: Sentry. Deploy after Seer cleanup #8943.

Remove the temporary GetSentry constructor/token bridge and human user_id accessor, leaving the regular actor-backed dataclass constructor. Migrate remaining human reads to actor identity or delegation and remove V1 wire methods and serialization version arguments. Endpoint authorization policy stays the same.

Stacked on Sentry writer #128111. Both writers must be fully deployed and all V1 work retired, as required by Seer cleanup.

GetSentry migration #22613 must be fully deployed, with old GetSentry web and worker processes retired, before this PR deploys. The earlier reader deliberately preserves those callers so the repositories can roll out separately.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 19, 2026
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from be92d63 to 93b2114 Compare October 20, 2026 20:10
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch 2 times, most recently from 60859ce to 08f6ccc Compare October 20, 2026 20:23
@gricha gricha changed the title ref(auth): Remove the V1 viewer context wire adapter ref(auth): Remove legacy viewer context APIs and wire format Oct 20, 2026
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from e268834 to f1fb280 Compare October 20, 2026 22:04
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 08f6ccc to 045a13f Compare October 20, 2026 22:06
@gricha gricha changed the title ref(auth): Remove legacy viewer context APIs and wire format ref(auth): Remove legacy viewer context APIs (final cleanup) Oct 20, 2026
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch 3 times, most recently from f9d12ce to f3abc96 Compare October 20, 2026 23:20
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 045a13f to 244303f Compare October 20, 2026 23:25
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from f3abc96 to bd29c82 Compare October 20, 2026 23:27
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 244303f to 691ffa8 Compare October 20, 2026 23:27
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from bd29c82 to 0a1f6d4 Compare October 20, 2026 23:58
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 691ffa8 to 34ccbc4 Compare October 21, 2026 04:10
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from 0a1f6d4 to be6fc44 Compare October 21, 2026 21:32
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 34ccbc4 to 88a4ed7 Compare October 21, 2026 21:35
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from be6fc44 to 5deaf7c Compare October 21, 2026 23:59
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 88a4ed7 to b910657 Compare October 22, 2026 00:01
@gricha
gricha marked this pull request as ready for review October 22, 2026 00:34
@gricha
gricha requested review from a team as code owners October 22, 2026 00:34
@gricha
gricha requested review from a team as code owners October 22, 2026 00:34
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from 5deaf7c to 2ae06f5 Compare October 22, 2026 22:55
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from b910657 to 1bef29c Compare October 22, 2026 22:55
gricha added a commit that referenced this pull request Oct 22, 2026
…28080)

**1/7 — READER: Sentry. Deploy first; current GetSentry keeps working.**

Use one frozen, actor-backed `ViewerContext`. Actor owns identity,
delegation, and elevation. `actor.id` is an `ActorId(type, id)` named
tuple; `actor.actor_id` is the scalar ID. Construction sites migrate
mechanically without changing endpoint authorization policy.

Read V1 and V2 into this model, while continuing to write V1.
Temporarily preserve the human `user_id` accessor and the
constructor/token replacement API used by current GetSentry. Legacy
token input is discarded. The bridge is removed together in [Sentry
cleanup #128112](#128112), after
the GetSentry migration deploys.

Fully deploy across web, workers, consumers, and all silos, then deploy
[2/7: Seer reader #8941](getsentry/seer#8941).
DB models and service-account issuance are separate work; new actor
producers wait until both writer PRs deploy.

---------

Co-authored-by: Codex <[email protected]>
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from 2ae06f5 to e2bedf4 Compare October 22, 2026 23:31
@gricha
gricha requested review from a team as code owners October 22, 2026 23:31
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 1bef29c to 9ad527e Compare October 22, 2026 23:31
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from e2bedf4 to 0b524a6 Compare October 23, 2026 17:05
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 9ad527e to 4bab5c3 Compare October 23, 2026 17:05
@gricha
gricha force-pushed the feat/viewer-context-actor-cutover branch from 0b524a6 to ef1f83b Compare October 23, 2026 17:29
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from 4bab5c3 to 2809cd1 Compare October 23, 2026 17:29
@sentry

sentry Bot commented Oct 23, 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 760 0 ✅ Unchanged

⚙️ sentry-frontend Snapshot Settings

Base automatically changed from feat/viewer-context-actor-cutover to master October 23, 2026 19:42
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch 2 times, most recently from 73d741c to bf0be78 Compare October 23, 2026 20:06

@azulus azulus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

agent, please check for the delegated_user_id pattern and abstract appropriately, apply DRY principles

Comment thread src/sentry/api/authentication.py Outdated
if vc is None or vc.user_id is None:
if vc is not None:
actor = vc.actor
user_id = actor.actor_id if actor.type == ActorType.USER else actor.delegated_user_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this run the other way? i.e. we shouldnt default to delegated_user_id? It feels like the default should be .actor_id unles we're in a special type that permits a delegated_user_id

if viewer_context is not None:
actor = viewer_context.actor
actor_user_id = (
actor.actor_id if actor.type == ActorType.USER else actor.delegated_user_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same case here and similar logic. This might be better as a utility function?

if viewer_context is not None:
actor = viewer_context.actor
actor_user_id = (
actor.actor_id if actor.type == ActorType.USER else actor.delegated_user_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

gricha and others added 3 commits October 23, 2026 14:57
Drop the temporary GetSentry constructor and token bridge, the human user_id accessor, and V1 wire support. Require the GetSentry caller migration and retirement of V1 work before deployment.

Co-Authored-By: Codex <[email protected]>
Replace the repeated `actor_id if USER else delegated_user_id` pattern with
one helper. Only agent actors resolve through delegated_user_id now; other
non-user actor types return None instead of trusting a delegated id.

Co-Authored-By: Jeremy Stanley <[email protected]>
@gricha
gricha force-pushed the ref/viewer-context-v2-only branch from ac5581d to de207a3 Compare October 23, 2026 22:21
@gricha
gricha merged commit 9fa5619 into master Oct 23, 2026
89 checks passed
@gricha
gricha deleted the ref/viewer-context-v2-only branch October 23, 2026 22:55
gricha added a commit that referenced this pull request Oct 23, 2026
Moves Sentry's ViewerContext model, contextvar and JWT encode/verify
onto the shared `sentry-viewercontext` package
([getsentry/viewercontext](https://github.com/getsentry/viewercontext)),
so Sentry, Seer and other services share one implementation of the wire
format.

`sentry.viewer_context` re-exports the library types, so call sites
don't change. Sentry keeps signing-key lookup from settings, the
early-adopter lookup, propagation metrics and its `set_viewer_context_*`
updaters. The library's `SuperuserAccess` is a plain dataclass, so the
Pydantic `sentry.types.superuser.SuperuserAccess` stays for RPC and
agent tokens and is converted where it enters or leaves the
ViewerContext (middleware, `ViewerContextAuthentication`, the agent
token endpoint).

Stacked on the cleanup PR (#128112). Locks the published
`sentry-viewercontext` 0.1.0 from the internal index
(getsentry/pypi#2660).

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Jeremy Stanley <[email protected]>
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