[Fix] Source-control credentials expire during long-running tasks - #1201
Merged
Conversation
Worker refresh used a fixed 45m cadence and ignored OAuth expiry, so a ~2h GitLab access token could sit dead in the sandbox after the last mint. Surface expiresAt from OAuth resolution and schedule refresh from it, with a 10m proactive token rotate.
Keep the soonest multi-provider expiry when merging tokens, return OAuth expiry from resolve metadata instead of process cache, and re-read a still-valid token when concurrent refresh fails instead of forcing reauthorization.
…tion Expiry-driven scheduling could push a refresh past a credential that reports no expiry: a run spanning GitHub and GitLab merged to GitLab's ~2h expiry and left the ~1h GitHub installation token dead for the remainder. Expiry now only ever shortens the interval. Also require proof that a peer actually rotated before trusting a connection re-read after a failed refresh, so a real invalid_grant is not masked into a retry loop, and classify OAuth tokens by what this process minted rather than guessing from token prefixes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…fetimes The proactive refresh skew and the worker refresh buffer were fixed windows sized for GitLab's ~2h default OAuth lifetime. An instance configured with a shorter TTL would sit permanently inside both windows, refreshing on every resolve and re-minting at the 60-second floor. Both now cap at a quarter of the token's life, so short-lived tokens still rotate before expiry without churn. The instance-reported lifetime is stored on the encrypted connection blob as an optional field, so an older release reading the same blob simply ignores it and a connection written before this change falls back to the default windows. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
7 tasks
mrubens
marked this pull request as ready for review
August 10, 2026 17:15
mrubens
requested review from
brunobergher,
daniel-lxs and
mrubens
as code owners
August 10, 2026 17:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Why this change was made
Long-running and resumed tasks could keep short-lived source-control credentials past expiration because provider lifetimes were not consistently propagated to the shared refresh scheduler. Independent provider implementations also handled timeouts, transient outages, and rotating refresh-token races differently.
Impact
Tasks using any supported source-control OAuth provider refresh credentials before they expire, including mixed-provider workspaces. Temporary provider outages no longer force reconnection, stalled token requests are bounded, and concurrent refreshes cannot discard a newer Azure DevOps delegated token.