Skip to content

fix(scripts-github): stop hammering the GitHub API after an auth failure - #36563

Open
Martin Hochel (Hotell) wants to merge 2 commits into
microsoft:masterfrom
Hotell:fix/github-changelog-auth-spam
Open

fix(scripts-github): stop hammering the GitHub API after an auth failure#36563
Martin Hochel (Hotell) wants to merge 2 commits into
microsoft:masterfrom
Hotell:fix/github-changelog-auth-spam

Conversation

@Hotell

@Hotell Martin Hochel (Hotell) commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Previous Behavior

When the changelog renderer resolves PRs for a release, it calls the GitHub API once per changelog entry. If the token is expired, revoked or blocked by policy, every one of those calls fails with 401/403.

The v8 release on 2026-06-30 logged 20 consecutive auth errors. A v9 release would log ~90. The actual problem — one bad token — was buried in the noise, which made the failure considerably harder to diagnose than it needed to be.

New Behavior

Short-circuit after the first auth failure. The failure is logged once, and subsequent lookups skip the request and fall back to no PR link (the changelog still renders, just without links).

Non-auth errors keep their existing per-entry behavior, since those are genuinely per-PR — a deleted PR, a race, a transient 5xx — and should not disable lookups for the rest of the run.

Also exports hasGitHubAuthFailed() / resetGitHubAuthFailure() so callers can detect the degraded state, and fixes a pre-existing lint error on the type import in pullRequests.ts.

Notes for reviewers

  • Behavior on the happy path is unchanged; this only affects the auth-failure case.
  • resetGitHubAuthFailure() exists so tests and long-lived processes are not stuck with a sticky module-level flag.
  • scripts/github is private, so no change file is required.

Independent of the other two PRs in this series (#36564, #36565) — mergeable in any order. Worth noting this one stands on its own merit regardless of the others: it improves diagnosability of any future token failure.

Related Issue(s)

N/A — follow-up to the 2026-06-30 v8 release incident.

When the changelog renderer resolves PRs for a release, it calls the GitHub
API once per changelog entry. If the token is expired, revoked or blocked by
policy, every one of those calls fails with 401/403 - a v8 release logged 20
consecutive auth errors, and a v9 release would log ~90. The real problem
(one bad token) was buried in the noise.

Short-circuit after the first auth failure: the failure is logged once, and
subsequent lookups skip the request and fall back to no PR link. Non-auth
errors keep their existing per-entry behaviour, since those are genuinely
per-PR (deleted PR, race, transient 5xx).

Also exports hasGitHubAuthFailed()/resetGitHubAuthFailure() so callers can
detect the degraded state, and fixes a pre-existing lint error on the type
import.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown

📊 Bundle size report

✅ No changes found

@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves resiliency and log signal-to-noise in the private scripts/github helper used by release tooling by short-circuiting GitHub PR lookups after the first authentication/authorization failure, avoiding repeated failing requests and repeated stack traces during changelog generation.

Changes:

  • Adds a module-level auth-failure latch to skip subsequent PR lookups after the first 401/403.
  • Logs a single Azure Pipelines warning (##vso[task.logissue]) on the first auth failure and degrades gracefully by returning no PR.
  • Exposes hasGitHubAuthFailed() and resetGitHubAuthFailure() and fixes a pre-existing lint issue by converting a value import to a type-only import.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
scripts/github/src/pullRequests.ts Adds auth-failure short-circuiting, one-time warning logging, and exported helpers for detecting/resetting degraded mode.
scripts/github/src/index.ts Re-exports the new auth-failure helper APIs from the package entrypoint.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/github/src/pullRequests.ts
Comment thread scripts/github/src/pullRequests.ts Outdated
…failure

GitHub overloads 403: it means 'forbidden' for a bad or policy-blocked token,
but also for primary and secondary rate limits. Reporting all of them as
'authentication failed' would send someone to rotate a perfectly good PAT in
the middle of a release - the exact misdirection this logging exists to stop.

Tell them apart via the rate-limit headers (retry-after, x-ratelimit-remaining)
and handle 429 too. Both still latch, since further lookups cannot succeed
either way, but the advice now matches the cause.

Also renames the module-level flag: it gates requests and backs
hasGitHubAuthFailed(), so 'authFailureLogged' understated what it controlled.
It now records why lookups are disabled, and hasGitHubAuthFailed() reports
only genuine auth failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Hotell
Martin Hochel (Hotell) marked this pull request as ready for review August 12, 2026 19:27
@Hotell
Martin Hochel (Hotell) requested a review from a team as a code owner August 12, 2026 19:27
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