Skip to content

Stop checking maintainer GitHub tokens before each package update - #1989

Merged
Seldaek merged 2 commits into
mainfrom
github-token-check-crash
Nov 23, 2026
Merged

Seldaek merged 2 commits into
mainfrom
github-token-check-crash

Conversation

@Seldaek

@Seldaek Seldaek commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Before updating a GitHub package, the update worker made its own request to GitHub to check that the maintainer's token was valid. This check had two bugs:

  • When GitHub sent no response (timeout, dropped connection), the update job crashed with Undefined array key 0 instead of updating the package.
  • Its HTTP status regex (HTTP/\s+) never matched a real status line. As a result it never wiped revoked tokens, and its IP allow list detection never ran.

The check is not needed anymore. Since #1895, when GitHub refuses a maintainer's token, LoggingHttpDownloader retries the repository request with the Packagist token, and it reports why the token was refused.

This PR removes the check and makes the update act on that refusal instead. The next updates then skip the refused token, so another maintainer's working token is used rather than the shared Packagist token:

GitHub refused the token because of Skipped for
An organization IP allow list That organization, 7 days (as before)
SAML SSO not authorized That organization, 1 day
A revoked or invalid token All organizations, 1 day, or until the maintainer links a new token
An exhausted rate limit Not skipped

Token selection moves to MaintainerGitHubTokenPicker. It keeps the existing IP allow list cache key, so skips already in place still apply. An update failure is only blamed on an organization's IP allow list when it was the maintainer's token that the allow list refused.

The worker made its own request to GitHub to validate a maintainer's token
before updating a package. It crashed the update job with "Undefined array
key 0" when GitHub sent no response, and its status regex never matched, so
it never actually detected invalid or IP allow listed tokens.

LoggingHttpDownloader already retries the repository request with the
Packagist token when GitHub refuses a maintainer's token (revoked, SAML SSO,
IP allow list, rate limit) and reports which of these it was, so the
pre-check is dropped. Token selection, including skipping a token an
organization IP allow list refused, moves to MaintainerGitHubTokenPicker.
When GitHub refuses a maintainer's token for a package's repository, the
update falls back to the Packagist token. The refused token was still picked
first on every later update, which hid other maintainers' working tokens.

The update now remembers why the token was refused and skips it for a while:
an organization IP allow list skips the token for that organization for a
week, SAML SSO for a day, and a revoked token for a day across all
organizations, or until the maintainer links a new one. Rate limits don't
skip the token.
@Seldaek
Seldaek merged commit 5d74275 into main Nov 23, 2026
8 checks passed
@Seldaek
Seldaek deleted the github-token-check-crash branch November 23, 2026 10:40
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.

1 participant