Skip to content

ci: make the GitHub Packages credential survive a pnpm major - #13

Merged
EliRobinson merged 1 commit into
mainfrom
ci/pnpm11-proof-package-auth
Sep 5, 2026
Merged

EliRobinson merged 1 commit into
mainfrom
ci/pnpm11-proof-package-auth

Conversation

@EliRobinson

Copy link
Copy Markdown
Owner

All three CI jobs authenticate to GitHub Packages by echoing the token into ~/.npmrc. That works today and stops working the day this repo moves to pnpm 11 — silently, and with an error that points at the wrong thing.

Found while upgrading the sibling react-native-template to pnpm 11, where it cost about an hour to diagnose.

What breaks

pnpm 11 keeps its own credential store and sends tokens only from there. A token in ~/.npmrc is still read and echoed back in pnpm's own diagnostics:

These authorization settings were found:
//npm.pkg.github.com/:_authToken=[hidden]

…while never reaching the request, which fails as:

[ERR_PNPM_FETCH_401] GET https://npm.pkg.github.com/@elirobinson%2Ftokens: Unauthorized
No authorization header was set for the request.

So pnpm reports the credential as present and configured, and the registry reports it as absent. That reads like a revoked token, not a config format change, which is the expensive part.

pnpm config set writes wherever the running pnpm actually reads, so it is correct on 9 and on 11.

The empty-secret guard

The same 401 appears when the secret exists but holds nothing, and the registry error names neither the secret nor the repository. react-native-template had exactly that — gh secret list showed NODE_AUTH_TOKEN present, and it was empty. Identifying it needed a temporary step logging the token's length in CI.

This adds a length check that fails with the command to fix it:

Error: NODE_AUTH_TOKEN is empty. Set it with: gh secret set NODE_AUTH_TOKEN --repo <owner/repo> (a GitHub token with read:packages).

Length only — never the value.

Note on this repo's secret

CI last passed on 2026-09-01. The account's GitHub token was rotated on 2026-09-04, so if this repo's NODE_AUTH_TOKEN held the old one, this PR's run is the first to find out. If it fails on the 401 rather than the guard, the secret needs re-setting; the guard only catches an empty value, not a revoked one.

Verification

pnpm config set <key> <value> is present in pnpm 9.15.0 (this repo's pinned version) and 11.25.0. No behaviour changes beyond where the credential is written, and the same three jobs run unchanged.

🤖 Generated with Claude Code

All three jobs wrote the token into ~/.npmrc. That works on pnpm 9, which this
repo pins, and silently stops working on pnpm 11: pnpm 11 keeps its own
credential store and sends tokens only from there, so a token in ~/.npmrc is
still listed back in pnpm's "These authorization settings were found" output
while never reaching the request. It fails as a 401 saying no authorization
header was set, which reads like a revoked token rather than a config change.

`pnpm config set` writes wherever the running pnpm actually reads, so it is
correct on 9 and on 11.

Also guards against an empty secret. The same 401 appears when NODE_AUTH_TOKEN
holds nothing, and the registry error names neither the secret nor the repo — the
sibling react-native-template hit exactly that and it took a token-length probe
in CI to identify. Checking the length up front turns it into an error message
that says what to run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@EliRobinson
EliRobinson merged commit 65b389d into main Sep 5, 2026
3 checks passed
@EliRobinson
EliRobinson deleted the ci/pnpm11-proof-package-auth branch September 5, 2026 04:43
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