Skip to content

fix(registry-client): getTokenByURL never probes env by request URL - #1869

Merged
ruyadorno merged 1 commit into
mainfrom
fix/token-by-url-known-keys
Sep 20, 2026
Merged

ruyadorno merged 1 commit into
mainfrom
fix/token-by-url-known-keys

Conversation

@ruy-bot

@ruy-bot ruy-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1844

  • drop full-URL getToken() fallback. Only hit on exact bare-origin URL, via the lossy VLT_TOKEN_* name (. - / → _), so lookalike hosts matched: https://npm-corp.com/ got VLT_TOKEN_https_npm_corp_com
  • matched key w/o token is skipped: token-less VLT_REGISTRY no longer shadows a shorter keychain key. VLT_REGISTRY + VLT_TOKEN_<key> still works

Not fixed: env-only VLT_TOKEN_<key> (no keychain / VLT_REGISTRY match) still sends nothing. Probing env per URL prefix would leak on every path of a lookalike host; safe fix needs the configured registry list → #1844.

Summary by CodeRabbit

  • Bug Fixes
    • Improved authentication token selection for registry URLs, including nested and path-specific registries.
    • Exact environment-based credentials now take precedence over stored credentials.
    • Prevented incomplete or ambiguous environment variable names from being used accidentally.
    • Requests without matching credentials now correctly report that no token is available, including for local file URLs.

- drop full-URL `getToken()` fallback: only hit on an exact bare-origin
  URL, through the lossy `VLT_TOKEN_*` name, so lookalike hosts matched
  (`https://npm-corp.com/` got `VLT_TOKEN_https_npm_corp_com`)
- skip matched keys w/o a token: token-less `VLT_REGISTRY` shadowed a
  shorter keychain key

Env-only `VLT_TOKEN_<key>` (no keychain / `VLT_REGISTRY` match) still
unresolved, needs the configured registry list.

Refs #1844

Co-Authored-By: Ruy Adorno <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: b093294b-b770-4377-a05f-32a2ef98fb76

📥 Commits

Reviewing files that changed from the base of the PR and between 7557c5e and fd3b47d.

📒 Files selected for processing (2)
  • src/registry-client/src/auth.ts
  • src/registry-client/test/auth.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Changes

Registry token lookup

Layer / File(s) Summary
Token lookup candidate resolution
src/registry-client/src/auth.ts
getTokenByURL checks matching registry candidates from longest to shortest and skips candidates without tokens. It no longer probes an origin-only environment key as a fallback.
Token lookup behavior tests
src/registry-client/test/auth.ts
Tests cover missing keychain entries, no-match URLs, lossy environment names, exact environment-key precedence, and path-specific registry tokens.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Suggested reviewers: ruyadorno

Merge Risk: ⚪ Minimal · up to fd3b4

No actionable merge-blocking risk remains in the reviewed change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: getTokenByURL no longer probes environment variables by the full request URL. It is concise and specific.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed: dependency version conflict. Check your lock file or package.json.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Sep 18, 2026 9:57pm UTC

Request Review

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🐰 Bencher Report

Projectvltpkg
Branchfix/token-by-url-known-keys
Testbedubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
vlt install: vue & cache-lockfile📈 view plot
🚷 view threshold
1,565.39 ms
(+2.62%)Baseline: 1,525.37 ms
1,677.90 ms
(93.29%)
vlt install: vue & cache-lockfile-node-modules📈 view plot
🚷 view threshold
379.62 ms
(+9.16%)Baseline: 347.76 ms
382.53 ms
(99.24%)
vlt install: vue & clean📈 view plot
🚷 view threshold
10,059.86 ms
(-2.17%)Baseline: 10,283.28 ms
11,311.61 ms
(88.93%)
vlt install: vue & lockfile📈 view plot
🚷 view threshold
3,923.74 ms
(+1.65%)Baseline: 3,860.09 ms
4,246.10 ms
(92.41%)
🐰 View full continuous benchmarking report in Bencher

@ruyadorno
ruyadorno merged commit 24609d6 into main Sep 20, 2026
24 checks passed
@ruyadorno
ruyadorno deleted the fix/token-by-url-known-keys branch September 20, 2026 01:20

This branch was successfully deployed

1 active deployment
Preview — fd3b47db Deployed Sep 18, 2026 by vercel[bot]
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