fix(cli): honor .npmrc auth keys written without a trailing slash [RED-897] [ship] - #1448
Merged
Merged
Conversation
…D-897]
resolveAuthHeader only probed the canonical slash-terminated nerf dart
spellings, so a hand-written //host/path:_authToken was invisible and the
embedded-package download went out unauthenticated. npm probes both
spellings at each depth of its walk and pnpm normalises the slashless one
at config load, so both are now probed, canonical first per depth. The
nerf-dart generator stays canonical; a dartSpellings helper expands each
finalised lookup candidate — unscoped, scope-qualified and path-form —
into both spellings, leaving the scoped/unscoped/path-form ordering
untouched.
Behaviour note: a slashless key that was previously ignored is now
honored, so one that references an unset ${VAR} now fails the download
and names the variable instead of silently falling through to a
shallower credential.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linear: RED-897
Follow-up deferred from RED-891 (#1444).
Affected Components
What
resolveAuthHeaderonly probed the canonical slash-terminated nerf dart spellings (//host/path/:_authToken), so a hand-written key without the trailing slash (//host/path:_authToken) was invisible to the walk and embedded-package downloads went out unauthenticated even with the credential right there in.npmrc. Both package managers tolerate the slashless spelling — npm probes both forms at each depth of its walk, pnpm normalises the slashless one to canonical at config load — so the CLI now does too.nerfDarts()keeps producing only canonical darts (the path form's${dart}${scope}/composition relies on the trailing-slash invariant); a smalldartSpellingshelper expands each finalised lookup candidate — unscoped, scope-qualified, and path-form — into both spellings, canonical first at each depth. The RED-891 scoped/unscoped/path-form ordering logic is untouched.The AI-context credentials reference documents the accepted spellings accordingly.
Notes for the Reviewer
Behaviour flip worth knowing: a slashless key that was previously ignored is now honored, so one that references an unset
${VAR}now fails the download and names the variable — instead of silently falling through to a shallower working credential (i.e. authenticating as an identity the config asked to replace). A new test pins this deliberately.Deliberate non-parity at one edge: at the request's own path depth npm probes only the URL's literal spelling, while this walk still tries canonical first there. Only observable with a key at exactly the request's full path — not a key anything writes; documented in the
resolveAuthHeaderdoc comment.New fixtures cover slashless keys at multiple depths, spelling precedence both ways, blank fall-through to the other spelling, scoped and path forms, no cross-spelling
username/_passwordpairing, andskipUnexpandabletolerance for the slashless path form.🤖 Generated with Claude Code