Skip to content

fix(resilience): restore expired-connection retry-budget probe in health sweep - #11672

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
jonlwheat2-gif:fix/health-token-retry-budget-boundary
Aug 26, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
jonlwheat2-gif:fix/health-token-retry-budget-boundary

Conversation

@jonlwheat2-gif

Copy link
Copy Markdown
Contributor

What was broken

checkConnection() in src/lib/tokenHealthCheck.ts stopped probing expired GitHub connections that still have retry budget. The health sweep's terminal-skip guard treated such connections as terminal, so a transient OAuth failure could never self-heal.

Red evidence (before)

On release/v3.8.51 tip (and PR #11644's CI):

✖ checkConnection probes an expired GitHub connection that still has retry budget
  AssertionError [ERR_ASSERTION]: retry budget remaining — the sweep must probe so a transient failure can self-heal

The test (tests/unit/token-health-no-refresh-token-expired-5326.test.ts:217, pinned by #11592) creates a GitHub access-token-only connection with testStatus: "expired", errorCode: "invalid_grant", retry budget remaining, and asserts lastHealthCheckAt gets written (i.e. the sweep probes it).

Root cause

Two recent PRs contradicted each other:

Fix

src/lib/tokenHealthCheck.ts — remove the carve-out from isRecoverableExpiredWithRetryBudget (lines 599–602; 6 deleted lines):

  const isRecoverableExpiredWithRetryBudget =
    conn.testStatus === "expired" &&
    conn.lastErrorType !== "account_deactivated" &&
-    // GitHub access-token-only connections have their own dedicated exemption
-    // (isRecoverableGithubCopilotNoRefresh above): ONLY the exact
-    // "no_refresh_token" shape self-heals. An "expired" GitHub connection for a
-    // different reason (e.g. invalid_grant) is genuinely terminal and must stay
-    // skipped, otherwise the generic retry-budget exemption below reopens #8182's
-    // wasted-probe fix for every "expired" GitHub connection.
-    !isGitHubAccessTokenOnlyConnection(conn) &&
    getExpiredRetryCount(conn) < EXPIRED_RETRY_MAX;

The account_deactivated case — the actual #8182 wasted-probe guard — is still skipped and still covered by its own test (checkConnection still skips an expired GitHub connection whose account is deactivated (#8182)).

Green evidence (after)

ℹ tests 7
ℹ pass 7
ℹ fail 0

Full file: tests/unit/token-health-no-refresh-token-expired-5326.test.ts (all 7 tests, including both halves of the boundary).

Files changed

File Change
src/lib/tokenHealthCheck.ts lines 599–602: drop !isGitHubAccessTokenOnlyConnection carve-out
changelog.d/fixes/11592-token-health-retry-budget-boundary.md new fragment

This fixes a base-red inherited failure on release/v3.8.51 (tracked in #11449) surfacing on PR #11644's CI.

…lth sweep

diegosouzapw#11592 pinned the token-health terminal-skip boundary: an expired connection
is exempt from the skip while it still has retry budget AND is not
account_deactivated, so transient OAuth failures can self-heal. diegosouzapw#11608's
merge-batch reintroduced a `!isGitHubAccessTokenOnlyConnection` carve-out that
contradicts that policy — a GitHub connection parked at "expired" with
invalid_grant and retry budget remaining was never probed again, so a
transient failure could never recover. Drop the carve-out; the
account_deactivated case (the real diegosouzapw#8182 wasted-probe guard) stays covered by
its own test.
@jonlwheat2-gif

Copy link
Copy Markdown
Contributor Author

Superseded by consolidated PR #11679, which includes this fix alongside the other five failing-test root causes (per the requested PR organization: one PR for docs drifts #11673, one consolidated PR for all failing tests).

@diegosouzapw
diegosouzapw merged commit e95a255 into diegosouzapw:release/v3.8.51 Aug 26, 2026
13 of 29 checks passed
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…lth sweep (diegosouzapw#11672)

Merged via /merge-batch (2026-08-26, v3.8.51). Boarded no worktree combinado; validação única: typecheck/complexity/cognitive-complexity/file-size/changelog verdes, lint nos mesmos 228 achados pré-existentes confirmados contra o tip puro, testes focados passando. Obrigado pela contribuição.
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.

2 participants