Skip to content

fix(egress): remint once on upstream 403 - #1694

Closed
sentry-junior[bot] wants to merge 1 commit into
mainfrom
fix/egress-remint-on-upstream-403
Closed

fix(egress): remint once on upstream 403#1694
sentry-junior[bot] wants to merge 1 commit into
mainfrom
fix/egress-remint-on-upstream-403

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Intermittent GitHub git-receive-pack 403s after a successful installation-token mint were failing the whole push path. Junior cleared the lease and recorded hard permission_denied with no retry, so mid-PR work looked like lost App write access.

This change treats an upstream 403 after credential injection as transient:

  • clear the cached lease
  • mint a replacement token and store it
  • retry the hop once
  • only then record permission_denied if the second attempt still fails

401 handling is unchanged. Local policy 403s are unchanged. Telemetry adds sandbox.egress.upstream_auth.retrying.

Requested by Ivan Dlugos.

--

View Junior Session [Sentry]

Treat injected-credential upstream 403 as transient: clear the cached lease, mint a replacement, and retry the hop once before recording permission denied.

Co-Authored-By: Ivan Dlugos <ivan.dlugos@sentry.io>
@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
junior-docs Ready Ready Preview Aug 25, 2026 9:49pm

Request Review

@sentry-junior

sentry-junior Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1700, which keeps the upstream-403 remint/retry and also simplifies host installation lease caching (drop per-sandbox/context and repo-scoped mint thrash).

@dcramer dcramer closed this Aug 26, 2026
dcramer added a commit that referenced this pull request Aug 26, 2026
Recovers the unfinished work from the mid-PR push thread.

**Problem**
Intermittent GitHub receive-pack 403s after a good installation-token
mint looked like Junior lost App write access mid-PR. The lease cache
was also keyed by sandbox `egressId` + `contextId` and repository lease
scope, so each new sandbox minted tokens too often and made the failure
more likely.

**Change**
Keep the real security boundary: the sandbox never sees tokens; host
egress injects them.

Simplify the machinery around it:
- cache installation leases on the host by `provider + grant` (shared
across sandboxes)
- keep user and broker grants bound to the actor
- stop repository filters on `installation-write` token mint bodies (use
full installed App permissions; repo allowlist stays policy and install
scope)
- refresh cached leases 5 minutes before expiry
- on upstream 403 after injection: clear lease → issue a new token →
retry once, then record permission denied

Supersedes the narrower retry-only draft in #1694.

Thread: https://sentry.slack.com/archives/C0AHB7N2JCR/p1787690872538269

<!-- junior-request-attribution:start -->
Requested by **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0B595QDZLL%3A1787710087.743069 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0B595QDZLL%3A1787710087.743069)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0B595QDZLL%3A1787710087.743069/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <david@sentry.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant