Skip to content

fix(cli): Refresh tokens with a corrupt issued_at - #1648

Merged
BYK merged 1 commit into
mainfrom
fix/cli-token-lifetime-ratio
Oct 23, 2026
Merged

BYK merged 1 commit into
mainfrom
fix/cli-token-lifetime-ratio

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Ports the token-lifetime fix that was left out of #1609 (from getsentry/cli#1200).

If a stored issued_at is at or after expires_at, the remaining-lifetime ratio comes out as Infinity (zero lifetime) or flips sign. With Infinity, refreshToken and the API client skip proactive refresh, and the token only refreshes after it has already expired.

The original PR clamped the lifetime to Math.max(1, …). That doesn't fix it: dividing the remaining milliseconds by 1ms still gives a huge ratio for any unexpired token, so refresh is still skipped. Instead, when the stored lifetime isn't positive, this falls back to DEFAULT_TOKEN_LIFETIME_MS, the same fallback used when issued_at is missing.

refreshToken and fetchWithRetry each computed the ratio inline. They now share getRemainingLifetimeRatio, so the two can't drift apart. Valid rows behave the same as before.

The project-cache read TTL from the original PR is still out of scope, per the archive note.

via BYK.

--

View Junior Session in Sentry

A stored issued_at at or after expires_at made the remaining-lifetime
ratio Infinity (or flipped its sign), so proactive refresh was skipped
until the token actually expired. Fall back to the default lifetime when
the stored lifetime is not positive, and share the ratio between
refreshToken and the API client so they cannot drift.

Ports the remaining fix from getsentry/cli#1200.

Co-Authored-By: BYK <[email protected]>
@vercel

vercel Bot commented Oct 23, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Oct 23, 2026 10:50pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Oct 23, 2026
@BYK
BYK enabled auto-merge (squash) October 23, 2026 22:55
@BYK
BYK merged commit efd2ebe into main Oct 23, 2026
26 checks passed
@BYK
BYK deleted the fix/cli-token-lifetime-ratio branch October 23, 2026 23:03

This branch was previously deployed

1 inactive deployment
Preview — 03b98370 Deployed Oct 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant