Skip to content

ref(seer): Send proxy_headers as JWT instead of legacy JSON+HMAC#113342

Merged
gricha merged 1 commit into
masterfrom
gricha/feat/proxy-headers-jwt
Apr 19, 2026
Merged

ref(seer): Send proxy_headers as JWT instead of legacy JSON+HMAC#113342
gricha merged 1 commit into
masterfrom
gricha/feat/proxy-headers-jwt

Conversation

@gricha

@gricha gricha commented Apr 17, 2026

Copy link
Copy Markdown
Member

get_proxy_headers() builds the auth Seer echoes back to Sentry on Code Mode callbacks. Today it uses the legacy two-header format — a JSON-serialized ViewerContext under X-Viewer-Context plus a separate X-Viewer-Context-Signature HMAC header. That format predates the JWT path used everywhere else in the ViewerContext flow.

Switch to a single X-Viewer-Context JWT, encoded with the existing encode_viewer_context() helper. Sentry's middleware already accepts both formats (JWT first, fallback to legacy with signature), so the receiving side needs no change. The JWT also carries an exp claim, which the legacy format didn't — strictly tighter than today.

Seer just echoes whatever it got as a dict, so the single-header response works on the Seer side without any change there.

Tests: 5 new cases in tests/sentry/seer/explorer/test_client_utils.py::TestGetProxyHeaders covering no-VC, VC-without-user, no-shared-secret, single-header shape, and full JWT payload roundtrip.

Refs RFC: Unified ViewerContext via ContextVar.

Today `get_proxy_headers()` builds the auth Seer echoes back to Sentry
on Code Mode callbacks using the legacy two-header format: a JSON-
serialized ViewerContext under `X-Viewer-Context` plus a separate
`X-Viewer-Context-Signature` HMAC header. That format predates the JWT
path used everywhere else in the ViewerContext flow.

Switch to a single `X-Viewer-Context` JWT, encoded with the existing
`encode_viewer_context` helper. Sentry's middleware already accepts both
formats (JWT first, falls back to legacy + signature), so the receiving
side needs no change. The JWT also carries an `exp` claim, which the
legacy format didn't — strictly tighter than the current behavior.

The Seer side (which currently echoes whatever headers it received as a
dict) doesn't care — it just hands the dict back. So a single-header
response Just Works on the seer side too.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 17, 2026
@gricha
gricha marked this pull request as ready for review April 17, 2026 19:45
@gricha
gricha requested a review from a team as a code owner April 17, 2026 19:45

@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.

assuming you tested locally and it works, lgtm

@gricha

gricha commented Apr 19, 2026

Copy link
Copy Markdown
Member Author

k landed another to seer side, confirmed this works locally

@gricha
gricha merged commit 79e5901 into master Apr 19, 2026
57 checks passed
@gricha
gricha deleted the gricha/feat/proxy-headers-jwt branch April 19, 2026 04:18
@gricha gricha added Trigger: Revert Add to a merged PR to revert it (skips CI) labels Apr 20, 2026
@getsentry-bot

Copy link
Copy Markdown
Contributor

PR reverted: 7d54c95

getsentry-bot added a commit that referenced this pull request Apr 20, 2026
…MAC (#113342)"

This reverts commit 79e5901.

Co-authored-by: gricha <875316+gricha@users.noreply.github.com>
@getsentry-bot

Copy link
Copy Markdown
Contributor

PR reverted: 7d54c95

gricha added a commit that referenced this pull request Apr 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components Trigger: Revert Add to a merged PR to revert it (skips CI)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants