Repository navigation
fix(github): managed GitHub identity stays expired after a refresh fails during a network outage - #187495
fix(github): managed GitHub identity stays expired after a refresh fails during a network outage#187495yutouchino wants to merge 3 commits into
Conversation
A GitHub refresh token is single-use, so a refresh whose outcome is unknown keeps its claim and is never retried automatically. The client marked every fetch rejection as dispatched, including DNS and TCP connect failures that never write the request. One refresh during an internet outage therefore left the managed identity stuck with an expired access token until a manual reconnect, and nothing was logged. - Classify fetch rejections whose cause chain proves a failed DNS lookup, connect or undici connect timeout (every address, for aggregates) as before-dispatch/not-attempted, so the claim is released and maintenance retries. Resets, closed sockets, aborts and coded wrappers stay unknown. - Share the failed-refresh settlement and warn on every failure: "will retry" when the claim is released, "reconnect GitHub" when it is retained.
A refresh whose outcome is unknown keeps its claim and is never retried, but the identity status still reported "failed", which the Control UI labels "Refresh failed — retrying". - Report a failed refresh that kept its claim as "expired" (labelled "Expired — reconnect required"); a released failure stays "failed". - Start each claimed attempt without the previous failure, so a claim plus a failure always means a stuck grant rather than an in-flight retry. - Document which refresh failures retry and which need reconnection.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
Document the non-null object invariants for the two unknown-property reads. Prune the obsolete closed-mock exemption now that the identity test preserves real OAuth-record exports.
Closes #187494
Related: #181262, #184774
What Problem This Solves
Fixes: a managed GitHub OAuth identity stays expired until someone reconnects it when its scheduled refresh runs during a DNS or network outage.
User Impact
User impact: managed GitHub identities recover on their own after a network outage. When a refresh genuinely cannot be retried safely, Agent Settings shows "Expired — reconnect required" instead of "Refresh failed — retrying", and the Gateway log says to reconnect.
Why This Change Was Made
GitHub refresh tokens are single-use, so a refresh whose outcome is unknown must keep its claim and not be replayed. But the GitHub client marked every
fetch()rejection as dispatched, including DNS lookup and TCP connect failures that never write the request. A single refresh during an outage therefore fenced a still-valid grant permanently.getaddrinfo), a connect failure (connect), or undici's connect timeout, with every branch proven for multi-address attempts. The claim is released, and maintenance retries. Resets after writing, closed sockets, aborts, timeouts and coded wrappers stay fenced exactly as before.expired(reconnect required). Each claimed attempt now starts without the previous failure, so "claim + failure" always means a stuck grant rather than an in-flight retry.docs/gateway/config-tools/github-identity.mdnow says which refresh failures retry and which need reconnection.The pre-connect predicate mirrors the private one in
src/infra/delivery-recovery.shared.ts. I left delivery recovery untouched to keep this PR focused; happy to consolidate if maintainers prefer.Evidence
github-oauth-client,github-oauth-records,github-tool-identity,github-identity-status-tool,github-oauth-lifecycle(+helpers, scheduling),github-personal-publication*,tools-github,delivery-recovery.shared).before-dispatchand recoverable;unknown;fetch(DNS, refused port, blackhole connect timeout at ~10.5 s, multi-address refusal, reset after write).oxlint,oxfmt,format:docs:check,tsgo:coreandtsgo:core:testare clean.pnpm installcould not run offline against this base's lockfile. Tests used the previous install, and the only lockfile delta is@noble/hashesinpackages/gateway-client, which these tests do not load. Proxy setups were not exercised: connect failures to a proxy are also classified as pre-dispatch, while proxy CONNECT rejections (for example 503) still stay fenced.This touches OAuth credential refresh, so it needs
/allow-security-sensitive-change.