Skip to content

refactor(registries): give the known-registry set one owner - #13591

Merged
zkochan merged 12 commits into
mainfrom
known-registries
Aug 2, 2026
Merged

zkochan merged 12 commits into
mainfrom
known-registries

Conversation

@zkochan

@zkochan zkochan commented Aug 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes pnpm/pnpm#13590.

The built-in aliases and the user's namedRegistries were combined independently at every place that needed them:

  • resolveNamedRegistries() in @pnpm/constants
  • a second call to it inside the same verifier factory, to build the URL prefix list
  • in pacquet, a hand-rolled chain sitting directly above a separate build_named_registry_prefixes()

The Rust pair had already drifted: the hand-rolled merge skipped the URL validation the other one applied.

That set feeds two consumers that look unrelated but are not — alias lookup for an entry that names its registry in the dep path, and the tarball-URL prefix list deciding which registry an entry carrying only a recorded URL is verified against. Splitting the merge across call sites is exactly what made adding the npmjs built-in look like a local change while it silently redirected verification traffic for lockfiles that record a registry.npmjs.org URL and name no alias at all. That consequence was caught by an unrelated normalization test that happened to use such a URL, not by anything at the edit site.

KnownRegistries now owns the merge and exposes both views, so a change to either input reaches both consumers or neither.

What's here

  • KnownRegistries in both stacks — createKnownRegistries() in @pnpm/constants, KnownRegistries::new() in pacquet-resolving-npm-resolver. merge_named_registries keeps its validating role and now delegates the merge itself, so there is one implementation rather than two that can disagree.
  • The prefix list is pinned by a test in both stacks, which was the issue's suggested first step. A new built-in cannot land without stating where it sends verification traffic.
  • tarballPrefixes is computed lazily on the TS side. Alias lookup runs per package (pkgSnapshotToResolution), while prefix matching only runs for entries with a recorded URL — eagerly parsing URLs there would have been a per-package regression.

A latent bug this surfaced

Writing the pinning test exposed one: the two built-in URLs are both exactly 27 characters, and sorting by length alone left their relative order to hash-map iteration, which varies between runs. My first version of the test failed for this reason.

The sort now tie-breaks lexicographically in both stacks. No routing outcome changes — two prefixes of equal length cannot both match one URL unless they are identical — but the list is now stable enough to assert on, which is the property the issue was asking for.

Verification

  • TypeScript: resolving.npm-resolver (334), lockfile.utils (18), deps.compliance.sbom (79), installing.deps-resolver (176).
  • Rust: pacquet-resolving-npm-resolver (351), pacquet-package-manager (856). cargo fmt, clippy, and rustdoc clean.

Not in scope

Per the issue: merging registries and namedRegistries (different contracts — one is recorded in the lockfile, the other is ambient config), and moving jsr into named registries (it legitimately needs scope routing for @jsr/* names, and converting it would churn every jsr user's lockfile keys).

Squash Commit Body

The built-in aliases and the user's `namedRegistries` were combined
independently at each place that needed them: `resolveNamedRegistries` in
constants, a second call inside the same verifier factory to build the URL
prefix list, and in pacquet a hand-rolled `chain` next to a separate
`build_named_registry_prefixes`. The Rust pair had already drifted — the
hand-rolled merge skipped the URL validation the other applied.

That set feeds two different consumers: alias lookup for an entry that names
its registry in the dep path, and the tarball-URL prefix list that decides
which registry an entry carrying only a recorded URL is verified against.
Splitting the merge across call sites is what made adding the `npmjs`
built-in look local while it silently redirected verification traffic for
lockfiles that record a registry.npmjs.org URL and name no alias at all.
That consequence was caught by an unrelated normalization test that happened
to use such a URL, not by anything at the edit site.

`KnownRegistries` now owns the merge and exposes both views, so a change to
either input reaches both consumers or neither. `createKnownRegistries`
computes the prefixes lazily because alias lookup runs per package while
prefix matching runs only for entries with a recorded URL.

Both stacks now pin the default prefix list in a test, so a new built-in
cannot land without stating where it sends verification traffic.

Writing that test surfaced a latent bug: the two built-in URLs are both 27
characters, and sorting by length alone left their relative order to hash-map
iteration, which varies between runs. The sort now tie-breaks
lexicographically in both stacks. No routing outcome changes — two prefixes
of equal length cannot both match one URL unless they are identical — but the
list is now stable enough to assert on.

Closes https://github.com/pnpm/pnpm/issues/13590

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Written by an agent (Claude Code, claude-opus-5).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Improved named registry resolution for registries with similar URL prefixes.
    • Added deterministic tarball URL matching.
    • Normalized registry configuration and ignored malformed custom entries.
    • Preserved built-in registries while supporting aliases and overrides.
    • Applied consistent registry handling across dependency resolution, lockfiles, and package inspection.
  • Tests

    • Expanded coverage for aliases, URL matching, prefix ordering, overrides, built-in registries, and invalid URLs.

zkochan added 3 commits August 2, 2026 17:04
The built-in aliases and the user's `namedRegistries` were combined
independently at each place that needed them: `resolveNamedRegistries` in
constants, a second call inside the same verifier factory to build the URL
prefix list, and in pacquet a hand-rolled `chain` next to a separate
`build_named_registry_prefixes`. The Rust pair had already drifted — the
hand-rolled merge skipped the URL validation the other applied.

That set feeds two different consumers: alias lookup for an entry that names
its registry in the dep path, and the tarball-URL prefix list that decides
which registry an entry carrying only a recorded URL is verified against.
Splitting the merge across call sites is what made adding the `npmjs`
built-in look local while it silently redirected verification traffic for
lockfiles that record a registry.npmjs.org URL and name no alias at all.
That consequence was caught by an unrelated normalization test that happened
to use such a URL, not by anything at the edit site.

`KnownRegistries` now owns the merge and exposes both views, so a change to
either input reaches both consumers or neither. `createKnownRegistries`
computes the prefixes lazily because alias lookup runs per package while
prefix matching runs only for entries with a recorded URL.

Both stacks now pin the default prefix list in a test, so a new built-in
cannot land without stating where it sends verification traffic.

Writing that test surfaced a latent bug: the two built-in URLs are both 27
characters, and sorting by length alone left their relative order to hash-map
iteration, which varies between runs. The sort now tie-breaks
lexicographically in both stacks. No routing outcome changes — two prefixes
of equal length cannot both match one URL unless they are identical — but the
list is now stable enough to assert on.

Closes #13590
…switch

The rename from resolveNamedRegistries to createKnownRegistries changed the
alphabetical order within the import, which simple-import-sort enforces.
build_named_registry_prefixes no longer exists; the prefix list is now
reached through KnownRegistries::tarball_prefixes. Caught by the pre-push
rustdoc gate.
Copilot AI review requested due to automatic review settings August 2, 2026 15:13

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The change centralizes named-registry normalization, alias lookup, and tarball-prefix generation in TypeScript and Rust. Resolver, lockfile, SBOM, and verification paths now use shared registry maps. Prefix matching uses longest-prefix ordering with deterministic lexicographic tie-breaking.

Changes

Known registry consolidation

Layer / File(s) Summary
TypeScript registry contract and construction
pnpm11/config/normalize-registries/*, pnpm11/config/pick-registry-for-package/*, pnpm11/core/types/*
Added NamedRegistries, normalization, URL validation, cached prefix generation, and deterministic ordering.
TypeScript registry integration
pnpm11/config/reader/*, pnpm11/deps/*, pnpm11/installing/*, pnpm11/lockfile/*, pnpm11/resolving/*
Replaced resolveNamedRegistries and updated consumers to use normalized registry maps and shared types.
Rust registry routing and verification
pnpm/crates/resolving-npm-resolver/src/*, pnpm/crates/package-manager/src/build_resolution_verifiers.rs
Renamed and changed the prefix helper, validated aliases before merging, and unified verifier routing inputs.
Release metadata
.changeset/known-registries-single-owner.md
Declared package releases and documented deterministic equal-length prefix matching.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ConfigReader
  participant normalizeNamedRegistries
  participant namedRegistryTarballPrefixes
  participant ResolutionVerifier
  participant RegistrySelector
  ConfigReader->>normalizeNamedRegistries: normalize built-in and user aliases
  normalizeNamedRegistries-->>ResolutionVerifier: provide alias-to-URL map
  normalizeNamedRegistries->>namedRegistryTarballPrefixes: provide normalized registry map
  namedRegistryTarballPrefixes-->>ResolutionVerifier: provide ordered URL prefixes
  ResolutionVerifier->>RegistrySelector: match lockfile tarball URL
  RegistrySelector-->>ResolutionVerifier: select registry for verification
Loading

Assessment against linked issues

Objective Addressed Explanation
Centralize known named-registry aliases and reverse-routing prefixes with user overrides and longest-prefix precedence [#13590] ✅
Build the known-registry set from all required registry sources, including scope registries [#13590] ❓ The changed code shows built-in and user-defined named registries, but it does not show scope registries being added to the shared set.

Possibly related PRs

  • pnpm/pnpm#13528: Both changes modify named-registry alias merging and verifier tarball-prefix routing.
  • pnpm/pnpm#13524: Publishes related package versions and changelog entries.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch known-registries

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Unify named-registry merge via KnownRegistries and stabilize tarball prefix ordering

🐞 Bug fix ✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Centralize built-in + user named-registry merging into a single KnownRegistries owner (TS + Rust).
• Fix nondeterministic tarball URL prefix ordering by adding a lexicographic tie-break.
• Add cross-stack tests that pin the default tarball-prefix routing list.
Diagram

graph TD
IN[("Built-ins + namedRegistries")] --> TSK["@pnpm/constants KnownRegistries"] --> AV["Alias→URL map"] --> TSC["TS consumers"]
TSK --> PV["Tarball prefixes"] --> TSV["TS verifier"]
IN --> RSK["pacquet KnownRegistries"]
RSK --> AV --> RV["Rust verifier"]
RSK --> PV --> RV
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep separate helpers (resolveNamedRegistries + buildTarballPrefixes) but co-locate calls
  • ➕ Smaller public API surface change in @pnpm/constants
  • ➕ Less refactoring churn in callers
  • ➖ Still easy for call sites to drift (e.g., one side forgets validation/sorting)
  • ➖ Harder to guarantee both alias routing and reverse routing always share identical inputs
2. Make built-in registries a single generated source shared by TS and Rust
  • ➕ Eliminates cross-language drift of BUILTIN_NAMED_REGISTRIES entirely
  • ➕ Could simplify future additions by enforcing one canonical list
  • ➖ Adds build/tooling complexity (codegen, release process coupling)
  • ➖ Doesn’t by itself solve ‘single owner’ concerns for derived views like prefixes
3. Persist routing digest/prefix list into lockfile metadata
  • ➕ Makes verification routing explicit and reproducible per lockfile
  • ➕ Decouples verifier behavior from evolving built-ins
  • ➖ Lockfile format change and migration burden
  • ➖ More surface area for backward compatibility and policy decisions

Recommendation: The PR’s approach (introducing a single KnownRegistries owner that exposes both alias and tarball-prefix views) is the best tradeoff: it directly prevents the observed drift class, keeps derived behavior consistent, and adds tests that pin the routing-impacting prefix list. Consider codegen/shared-source only if cross-language built-in drift becomes a recurring maintenance issue.

Files changed (11) +284 / -90

Enhancement (1) +68 / -9
index.tsAdd TS KnownRegistries API with lazy tarballPrefixes computation +68/-9

Add TS KnownRegistries API with lazy tarballPrefixes computation

• Replaces 'resolveNamedRegistries()' with 'createKnownRegistries()' returning a prototype-free alias map plus lazily computed, normalized tarball URL prefixes. Ensures deterministic prefix ordering via length + lexicographic tie-break.

pnpm11/core/constants/src/index.ts

Bug fix (1) +67 / -29
named_registry.rsIntroduce Rust KnownRegistries and stabilize tarball prefix sorting +67/-29

Introduce Rust KnownRegistries and stabilize tarball prefix sorting

• Adds 'KnownRegistries' to own the merged registry map and computed tarball URL prefixes. Switches prefix sorting to length-first with lexicographic tie-break to make ordering deterministic, and routes 'merge_named_registries()' through the new owner.

pnpm/crates/resolving-npm-resolver/src/named_registry.rs

Refactor (6) +27 / -43
create_npm_resolution_verifier.rsWire verifier to Rust KnownRegistries for shared alias+prefix views +8/-9

Wire verifier to Rust KnownRegistries for shared alias+prefix views

• Replaces ad-hoc merging of built-in and user registries with 'KnownRegistries::new()'. Uses the shared instance to source both tarball prefix routing and alias-to-URL lookup to prevent drift.

pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier.rs

lib.rsRe-export KnownRegistries from resolving-npm-resolver crate +2/-2

Re-export KnownRegistries from resolving-npm-resolver crate

• Updates public exports to include 'KnownRegistries' and remove the old prefix-builder export, aligning the crate API with the new ownership model.

pnpm/crates/resolving-npm-resolver/src/lib.rs

collectComponents.tsSwitch SBOM collection to KnownRegistries.byAlias lookup +2/-2

Switch SBOM collection to KnownRegistries.byAlias lookup

• Updates registry URL lookup for registry-qualified dep paths to use 'createKnownRegistries(...).byAlias', keeping behavior consistent with the new central merge point.

pnpm11/deps/compliance/sbom/src/collectComponents.ts

updateLockfile.tsUse KnownRegistries.byAlias when updating lockfile registry aliases +2/-2

Use KnownRegistries.byAlias when updating lockfile registry aliases

• Replaces direct calls to the old resolver with the new 'KnownRegistries' alias map for consistent registry alias resolution during lockfile updates.

pnpm11/installing/deps-resolver/src/updateLockfile.ts

pkgSnapshotToResolution.tsRoute pkgSnapshot registry alias resolution through KnownRegistries +2/-2

Route pkgSnapshot registry alias resolution through KnownRegistries

• Updates per-package snapshot resolution to read registry URLs from 'KnownRegistries.byAlias', centralizing alias handling and preserving prototype-free safety.

pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts

createNpmResolutionVerifier.tsUnify TS verifier routing via KnownRegistries and readonly prefixes +11/-26

Unify TS verifier routing via KnownRegistries and readonly prefixes

• Removes duplicated merge + prefix normalization logic and instead uses a single 'KnownRegistries' instance for both alias routing and tarball URL reverse routing. Tightens 'namedRegistryPrefixes' type to 'readonly string[]'.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts

Tests (2) +111 / -9
tests.rsAdd Rust tests pinning built-in prefix list and malformed-URL handling +38/-9

Add Rust tests pinning built-in prefix list and malformed-URL handling

• Adds assertions that the default reverse-routing prefix list matches built-ins exactly and that malformed user URLs are dropped rather than poisoning the list. Updates existing tests to use 'KnownRegistries' instead of the removed prefix-builder.

pnpm/crates/resolving-npm-resolver/src/named_registry/tests.rs

knownRegistries.test.tsAdd TS tests pinning tarballPrefixes and prototype-free alias map +73/-0

Add TS tests pinning tarballPrefixes and prototype-free alias map

• Adds Jest tests that pin the default built-in tarball prefix list, validate override behavior and trailing slashes, drop malformed URLs, and assert prototype-free alias lookup to prevent crafted-alias resolution.

pnpm11/resolving/npm-resolver/test/knownRegistries.test.ts

Other (1) +11 / -0
known-registries-single-owner.mdAdd changeset noting stable tarball-prefix matching order +11/-0

Add changeset noting stable tarball-prefix matching order

• Introduces a changeset bumping multiple packages and documenting a fix for nondeterministic tarball URL prefix matching when two registry URLs have equal length.

.changeset/known-registries-single-owner.md

@greptile-apps

greptile-apps Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (9): Last reviewed commit: "chore(registries): drop the diff this re..." | Re-trigger Greptile

@qodo-code-review

qodo-code-review Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (2) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Verifier build can panic ✓ Resolved 🐞 Bug ☼ Reliability
Description
build_resolution_verifiers() now unwraps merge_named_registries() with .expect(), so an
invalid/malicious namedRegistries config triggers a process panic instead of a structured ERR_PNPM_*
error. This is reachable on the main install path because install.rs builds resolution verifiers
before the later resolver setup that currently validates named registries.
Code

pnpm/crates/package-manager/src/build_resolution_verifiers.rs[R113-116]

+        named_registries: merge_named_registries(
+            &config.named_registries.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
+        )
+        .expect("named registries were validated at install setup"),
Relevance

●●● Strong

Team previously replaced .expect() panic with propagated structured error (PR #13059).

PR-#13059

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The verifier builder unwraps a fallible merge/validation function, and the main install path invokes
this builder before the later code that currently performs named registry validation for the
resolver chain.

pnpm/crates/package-manager/src/build_resolution_verifiers.rs[109-116]
pnpm/crates/package-manager/src/install.rs[1310-1322]
pnpm/crates/resolving-npm-resolver/src/named_registry.rs[86-110]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`build_resolution_verifiers()` calls `merge_named_registries(...).expect(...)`, which panics on invalid alias/URL instead of returning a structured diagnostic. This can crash `pnpm install` before any meaningful error is surfaced.

### Issue Context
The install flow constructs resolution verifiers early; the current codebase also performs named-registry validation later during resolver chain setup, so the "already validated" invariant does not hold in all entry paths.

### Fix Focus Areas
- Add an error variant to `BuildVerifiersError` (or return a dedicated error type) that can carry `MergeNamedRegistriesError` and its diagnostic code.
- Replace `.expect(...)` with `map_err(...)` and propagate the error to `InstallError`.

- pnpm/crates/package-manager/src/build_resolution_verifiers.rs[109-116]
- pnpm/crates/package-manager/src/install.rs[1310-1322]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Named registry URL leaks 🐞 Bug ⛨ Security
Description
BuildVerifiersError::InvalidNamedRegistries transparently displays MergeNamedRegistriesError,
whose Display string includes the full user-provided registry URL; if that URL contains
credentials (userinfo), they can be emitted into stderr/CI logs on configuration failure.
Code

pnpm/crates/package-manager/src/build_resolution_verifiers.rs[R52-55]

+    #[display("{source}")]
+    #[diagnostic(transparent)]
+    InvalidNamedRegistries {
+        #[error(source)]
Relevance

●●● Strong

Team has repeatedly accepted redacting/sanitizing credential-bearing URLs in diagnostics/log output
(e.g. #13371, #13207, #13549).

PR-#13371
PR-#13207
PR-#13549

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new wrapper error is rendered transparently and displayed as the inner error. The inner error’s
Display message interpolates the full url field directly, so any userinfo present in the
configured URL is printed verbatim when this diagnostic is surfaced from verifier construction.

pnpm/crates/package-manager/src/build_resolution_verifiers.rs[47-57]
pnpm/crates/resolving-npm-resolver/src/named_registry.rs[41-57]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`InvalidNamedRegistries` is rendered transparently and displayed as `{source}`. The underlying `MergeNamedRegistriesError::InvalidUrl` message includes the full `{url}` string, which can contain credentials (e.g. `https://user:pass@host/`). This can leak secrets into terminal output, CI logs, or bug reports when the install fails due to invalid named registry configuration.

### Issue Context
This error path is newly reachable from `build_resolution_verifiers()` (verifiers are built before the resolver chain, and on the frozen path the chain doesn’t run).

### Fix Focus Areas
- pnpm/crates/package-manager/src/build_resolution_verifiers.rs[47-57]
- pnpm/crates/resolving-npm-resolver/src/named_registry.rs[41-57]

### Suggested fix
- Redact URL userinfo before formatting diagnostics.
 - Preferred: change `MergeNamedRegistriesError` display formatting so it prints a sanitized URL (e.g. strip/replace `username:password@` when `Url::parse` succeeds; if parsing fails, conservatively mask any `...@` userinfo-like prefix).
 - Alternative: keep `MergeNamedRegistriesError` unchanged but make `BuildVerifiersError::InvalidNamedRegistries` *not* `transparent`, and instead map to a redacted message while preserving the same diagnostic code.
- Add/adjust a small test to ensure a URL with userinfo does not echo credentials in the rendered error string.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. normalizeNamedRegistries declared too early 📘 Rule violation ⚙ Maintainability
Description
normalizeNamedRegistries is declared before its first usage in the same file
(DEFAULT_NAMED_REGISTRIES initialization), violating the local declaration-order rule. This
reduces readability by forcing readers to jump past declarations before seeing real usage context.
Code

pnpm11/config/normalize-registries/src/index.ts[R39-40]

+/** Shared, like `DEFAULT_REGISTRIES`, so per-package callers can cache on its identity. */
+const DEFAULT_NAMED_REGISTRIES = normalizeNamedRegistries({})
Relevance

●●● Strong

Declaration-order rule often enforced; similar “move function below first use” suggestions accepted
(PR #12964).

PR-#12964

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713432 requires TypeScript function declarations to appear only after their first
usage within the same file. Here, normalizeNamedRegistries is defined above, and then the first
in-file usage appears later when DEFAULT_NAMED_REGISTRIES is initialized by calling
normalizeNamedRegistries({}).

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/config/normalize-registries/src/index.ts[32-36]
pnpm11/config/normalize-registries/src/index.ts[39-40]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A top-level exported function declaration appears before its first call site in the same file, contrary to the required declaration order.

## Issue Context
This rule is intended to keep files usage-first, making it easier to understand why a helper exists before reading its full implementation.

## Fix Focus Areas
- pnpm11/config/normalize-registries/src/index.ts[32-36]
- pnpm11/config/normalize-registries/src/index.ts[39-40]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Mutable shared registry defaults 🐞 Bug ⛨ Security
Description
normalizeNamedRegistries() returns a shared DEFAULT_NAMED_REGISTRIES object that is not frozen, so
any mutation (accidental or in-process) changes built-in registry routing for subsequent callers and
can create initialization-order dependent behavior with createKnownRegistries()’s identity-based
cache.
Code

pnpm11/config/normalize-registries/src/index.ts[R34-37]

+  if (namedRegistries == null) return DEFAULT_NAMED_REGISTRIES
+  return {
+    ...BUILTIN_NAMED_REGISTRIES,
+    ...namedRegistries,
Relevance

●●● Strong

Team previously accepted eliminating shared mutable singleton state escaping (ReadonlySet/avoid
shared empty singleton) in PR #12467.

PR-#12467

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The default path returns a shared object, and the caching layer explicitly keys on map identity and
assumes it is not mutated; leaving the shared default mutable makes routing/configuration globally
alterable within the process and can lead to inconsistent cached snapshots vs. the (mutated) source
map.

pnpm11/config/normalize-registries/src/index.ts[20-48]
pnpm11/config/pick-registry-for-package/src/index.ts[56-92]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`normalizeNamedRegistries()` returns a shared `DEFAULT_NAMED_REGISTRIES` object when called with no user input. That shared object is currently mutable, so any mutation will affect all later callers in-process and can lead to inconsistent behavior with `createKnownRegistries()` caching (which assumes the map is not mutated).

## Issue Context
- The code explicitly relies on object identity sharing for performance/caching.
- Returning a mutable singleton makes state cross-contaminate between installs/commands in the same Node process.

## Fix Focus Areas
- pnpm11/config/normalize-registries/src/index.ts[33-48]
- pnpm11/config/pick-registry-for-package/src/index.ts[56-92]

## Suggested fix
1. Make the shared default immutable:
  - `const DEFAULT_NAMED_REGISTRIES = Object.freeze({ ...BUILTIN_NAMED_REGISTRIES }) as NamedRegistries`
2. Consider also freezing the merged object returned for the non-null case to match the documented invariant (“not mutated afterwards”):
  - `return Object.freeze({ ...BUILTIN_NAMED_REGISTRIES, ...namedRegistries }) as NamedRegistries`
3. If full freezing could be breaking, at minimum freeze the shared default singleton (the highest-risk case).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (3)
5. byAlias hides undefined ⊘ Outdated 🐞 Bug ⚙ Maintainability
Description
KnownRegistries.byAlias is typed as Record<string, string>, but createKnownRegistries() only
populates a finite set of keys (built-ins + user entries), so arbitrary alias lookups can return
undefined at runtime without the type forcing a guard. This weakens compile-time enforcement
around lockfile/config-derived alias lookups and increases the risk of future unguarded dereferences
or mis-handling on untrusted input paths.
Code

pnpm11/config/pick-registry-for-package/src/index.ts[43]

+  readonly byAlias: Record<string, string>
Relevance

●● Moderate

No prior accepted changes for Record typing; related named-registry map hardening was
rejected/partial in #13528.

PR-#13528

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The interface promises a string for any string key, but the implementation constructs byAlias only
from two sources (built-ins and optional user config), so any other key will be absent and thus
resolve to undefined at runtime.

pnpm11/config/pick-registry-for-package/src/index.ts[33-56]
pnpm11/config/pick-registry-for-package/src/index.ts[66-71]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`KnownRegistries.byAlias` is declared as `Record<string, string>`, but unknown aliases are not present on the underlying null-prototype object and therefore evaluate to `undefined` at runtime. This makes it easy for future call sites to skip the intended “fail closed on unknown alias” guard because TypeScript will not require handling `undefined`.

### Issue Context
The map is built from `BUILTIN_NAMED_REGISTRIES` plus optional `namedRegistries`, so only those keys can exist.

### Fix Focus Areas
- pnpm11/config/pick-registry-for-package/src/index.ts[33-71]

### Suggested change
- Change the type to reflect reality, e.g.:
 - `readonly byAlias: Record<string, string | undefined>` and
 - `createKnownRegistries(namedRegistries?: Record<string, string | undefined>): KnownRegistries`
- Alternatively, keep the internal record private and expose an accessor `getRegistryByAlias(alias: string): string | undefined` to make the safe usage pattern explicit.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Hot path allocates wrappers ⊘ Outdated 🐞 Bug ➹ Performance
Description
pkgSnapshotToResolution() now calls createKnownRegistries() for each registry-qualified package
only to read byAlias, allocating a KnownRegistries wrapper and getter closure per call. This
function is invoked per package during lockfile graph building, increasing per-package overhead and
GC pressure compared to the previous plain merged-record helper.
Code

pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[R52-53]

+    registry = createKnownRegistries(opts.namedRegistries).byAlias[registryName]
    if (!registry) {
Relevance

●● Moderate

Team has accepted TS hot-path perf fixes, but no direct precedent on caching
createKnownRegistries/byAlias wrapper allocations.

PR-#13504
PR-#13289

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
createKnownRegistries() returns a wrapper object with a lazy getter, so creating it has more
allocation overhead than the previous plain record. pkgSnapshotToResolution() now instantiates
this wrapper when it sees registryName, and lockfileToDepGraph calls pkgSnapshotToResolution()
while iterating packages, making the wrapper allocation part of a per-package path.

pnpm11/core/constants/src/index.ts[73-87]
pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[49-57]
pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[297-309]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pkgSnapshotToResolution()` is called in per-package loops and now constructs a full `KnownRegistries` object just to read `knownRegistries.byAlias[registryName]`. This adds an extra wrapper object + getter closure allocation per call.

## Issue Context
`createKnownRegistries()` intentionally uses a lazy getter for `tarballPrefixes`, which is great for verifier performance. But many call sites (like `pkgSnapshotToResolution`) only need alias lookup and never touch `tarballPrefixes`, so paying for the wrapper repeatedly in hot paths is unnecessary.

## Fix Focus Areas
- pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts[49-57]
- pnpm11/core/constants/src/index.ts[73-87]
- pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts[297-309]

### Suggested approach (pick one)
1) Add a map-only helper in `@pnpm/constants` (single merge owner still):
  - e.g. `createKnownRegistriesByAlias(namedRegistries?): Record<string,string>` that returns the null-prototype merged map with no wrapper/getter.
  - Implement `createKnownRegistries()` in terms of it.
  - Switch hot-path alias-only lookups (`pkgSnapshotToResolution`, SBOM, etc.) to use the map-only helper.

2) Thread a precomputed `KnownRegistries` down hot paths:
  - Extend `PkgSnapshotToResolutionOptions` to optionally accept `knownRegistries` (or `byAlias`) so callers that already process many packages can compute once and reuse.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Wasted prefix parsing ✓ Resolved 🐞 Bug ➹ Performance
Description
merge_named_registries() now constructs KnownRegistries::new() and immediately discards
tarball_prefixes, so it still parses/sorts registry URLs even though the caller only needs the
alias map. This adds avoidable CPU and allocations in the named-registries merge/validation path.
Code

pnpm/crates/resolving-npm-resolver/src/named_registry.rs[103]

+    Ok(KnownRegistries::new(user_defined).into_by_alias())
Relevance

●● Moderate

No prior reviews found on avoiding eager URL parsing in KnownRegistries::new; perf suggestions
mixed/unclear.

PR-#13549

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The diff changes merge_named_registries() to return KnownRegistries::new(...).into_by_alias(),
and KnownRegistries::new() always calls build_tarball_prefixes() which parses URLs and sorts the
resulting prefixes—work that merge_named_registries() no longer uses.

pnpm/crates/resolving-npm-resolver/src/named_registry.rs[82-105]
pnpm/crates/resolving-npm-resolver/src/named_registry.rs[124-136]
pnpm/crates/resolving-npm-resolver/src/named_registry.rs[163-186]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`merge_named_registries()` validates user entries but then returns `KnownRegistries::new(user_defined).into_by_alias()`. `KnownRegistries::new()` eagerly builds `tarball_prefixes` by parsing and normalizing every URL; this work is wasted in `merge_named_registries()` because only the alias map is returned.

## Issue Context
This PR introduces `KnownRegistries` as a single owner for both alias routing and tarball-prefix routing, but `merge_named_registries()` is a map-only API and should not pay the cost of computing prefixes.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/named_registry.rs[82-160]

### Suggested approach
- Split construction into two steps:
 - a helper that only merges built-ins + user entries into `by_alias` (no URL parsing)
 - a `KnownRegistries` constructor that takes a prebuilt `by_alias` and computes `tarball_prefixes`
- Then:
 - `merge_named_registries()` returns the merged `by_alias` directly (after validation)
 - verifier paths keep using `KnownRegistries` (which computes prefixes)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

8. Missing comma in Object.assign 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The multi-line Object.assign(...) call in normalizeNamedRegistries() omits a trailing comma
after the last argument, which violates the repo’s TypeScript trailing-comma requirement and makes
future edits noisier.
Code

pnpm11/config/normalize-registries/src/index.ts[R34-36]

+    BUILTIN_NAMED_REGISTRIES,
+    namedRegistries
+  )
Relevance

● Weak

Trailing-comma style suggestions are repeatedly rejected (e.g., multi-line calls/signatures) in PRs
#13477 and #12833.

PR-#13477
PR-#12833

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TypeScript constructs. In
normalizeNamedRegistries(), the last argument in a multi-line Object.assign(...) call
(namedRegistries) does not end with a comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/config/normalize-registries/src/index.ts[32-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`normalizeNamedRegistries()` builds a multi-line `Object.assign(...)` argument list but the last argument (`namedRegistries`) has no trailing comma. This violates the TypeScript trailing-comma policy and increases diff churn when adding/reordering arguments.

## Issue Context
The compliance rule requires trailing commas in multi-line TypeScript collections and multi-line constructs.

## Fix Focus Areas
- pnpm11/config/normalize-registries/src/index.ts[32-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. NamedRegistries not enforced 🐞 Bug ⛨ Security ⭐ New
Description
NamedRegistries is documented as preventing raw namedRegistries from reaching consumers, but its
[name: string]: string index signature makes Record<string,string> structurally assignable, so
normalization/prototype-safety is not actually enforced by the type. This is security-relevant
because future code may rely on this “enforcement” and accidentally accept unnormalized/protoful
maps on lockfile/config-derived alias lookup paths.
Code

pnpm11/core/types/src/misc.ts[R22-26]

+/**
+ * The required keys are the enforcement: a raw `namedRegistries` from user
+ * config does not satisfy this type, so it cannot reach a consumer without
+ * passing through `normalizeNamedRegistries`. Widening it is how adding a
+ * built-in gets acknowledged.
Relevance

● Weak

Similar named-registries hardening/prototype-safety concerns were rejected
(Object.hasOwn/fail-closed) in PR #13528.

PR-#13528

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The type docstring claims required keys enforce normalization, but the interface also declares a
string index signature, which makes it structurally compatible with broad string-keyed maps; runtime
normalization is actually implemented in normalizeNamedRegistries via
Object.assign(Object.create(null), ...) and not guaranteed by the type alone.

pnpm11/core/types/src/misc.ts[22-32]
pnpm11/config/normalize-registries/src/index.ts[20-37]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`NamedRegistries` is introduced with a comment claiming the required keys enforce that raw user config cannot satisfy the type without going through `normalizeNamedRegistries`. In TypeScript’s structural type system, the current shape (`gh`, `npmjs`, plus `[name: string]: string`) does **not** prove the value is normalized or prototype-free; a value typed as `Record<string, string>` can be passed as `NamedRegistries` without any runtime normalization.

This is a security-adjacent maintainability risk: future call sites may skip `normalizeNamedRegistries()` under a false sense of compile-time enforcement, reintroducing prototype-related bypasses the PR explicitly tries to avoid.

### Issue Context
- The type’s docstring claims the required keys are the enforcement.
- `normalizeNamedRegistries()` is the runtime mechanism that actually constructs the null-prototype merged map.

### Fix Focus Areas
- pnpm11/core/types/src/misc.ts[22-32]
- pnpm11/config/normalize-registries/src/index.ts[20-40]

### Recommended fix approaches (pick one)
1) **Correct the contract comment (minimal change):**
  - Update the `NamedRegistries` docstring to explicitly state that it is a *shape* type and does not guarantee normalization/prototype-free behavior by itself.
  - Add a clear note that callers must route untrusted inputs through `normalizeNamedRegistries()`.

2) **Add a branded/opaque type (stronger enforcement):**
  - Introduce a brand on `NamedRegistries` (e.g. a `unique symbol` property) so that plain `Record<string,string>` is not assignable without an explicit unsafe cast.
  - Have `normalizeNamedRegistries()` be the only function that returns the branded type.
  - Keep the runtime null-prototype construction as-is.

Either way, ensure the type-level documentation matches what the type system can actually enforce.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


10. Extra clones in registry merge 🐞 Bug ➹ Performance
Description
build_resolution_verifiers() clones config.named_registries into a temporary HashMap solely to
call merge_named_registries(), which then clones user entries again into the merged output, adding
avoidable allocations during verifier construction.
Code

pnpm/crates/package-manager/src/build_resolution_verifiers.rs[R106-108]

+    let named_registries = merge_named_registries(
+        &config.named_registries.iter().map(|(k, v)| (k.clone(), v.clone())).collect(),
+    )
Relevance

● Weak

Similar “avoid extra HashMap build/clones” micro-optimizations were previously rejected as not worth
complexity (#12995, #13532).

PR-#12995
PR-#13532

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Config::named_registries is a BTreeMap, forcing a conversion. The new code constructs a cloned
HashMap for the call, and merge_named_registries then clones each key/value again into the
merged output map.

pnpm/crates/package-manager/src/build_resolution_verifiers.rs[102-110]
pnpm/crates/config/src/lib.rs[966-975]
pnpm/crates/resolving-npm-resolver/src/named_registry.rs[86-110]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`config.named_registries` is a `BTreeMap`, but `merge_named_registries()` requires `&HashMap<String, String>`. The current implementation builds a temporary `HashMap` by cloning all entries, then `merge_named_registries()` loops and clones the entries again into the returned merged `HashMap`.

### Issue Context
This runs during verifier construction (per install). The typical map size is likely small, so this is low severity, but it’s still unnecessary work.

### Fix Focus Areas
- pnpm/crates/package-manager/src/build_resolution_verifiers.rs[102-110]
- pnpm/crates/config/src/lib.rs[966-975]
- pnpm/crates/resolving-npm-resolver/src/named_registry.rs[86-110]

### Suggested fix
- Adjust `merge_named_registries` to accept a more general input type (e.g. `impl IntoIterator<Item = (&String, &String)>` or a generic `&impl MapLike`) so callers can pass `&BTreeMap` directly.
- Or provide a second helper like `merge_named_registries_from_iter(...)` used by `build_resolution_verifiers`.
- Ensure the merge/validation still performs only one set of clones into the final merged map.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (3)
11. Verifier skips registry normalization ✓ Resolved 🐞 Bug ⛨ Security
Description
createNpmResolutionVerifier() uses opts.namedRegistries as-is when provided, rather than enforcing
normalizeNamedRegistries(), so a plain object can allow lockfile-provided registry names like
"constructor" to resolve to inherited Object.prototype values and bypass the intended "unknown
registry" fail-closed guard. This can then flow a non-URL value into registry URL construction/fetch
paths and crash or misroute verification in untyped/embedder call paths.
Code

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[R136-137]

+  const mergedNamedRegistries = opts.namedRegistries ?? normalizeNamedRegistries()
+  const namedRegistryPrefixes = namedRegistryTarballPrefixes(mergedNamedRegistries)
Relevance

● Weak

Similar prototype/inherited-property hardening for namedRegistries lookup was explicitly rejected in
PR #13528.

PR-#13528

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The normalization helper documents that null-prototype is required to prevent crafted registry names
from resolving to Object.prototype and bypassing if (!registry) guards;
createNpmResolutionVerifier currently skips that normalization when a caller supplies the map, then
uses the value as a registry string in downstream fetch/URL code paths.

pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[136-138]
pnpm11/config/normalize-registries/src/index.ts[20-36]
pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[488-525]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`createNpmResolutionVerifier()` currently does:
```ts
const mergedNamedRegistries = opts.namedRegistries ?? normalizeNamedRegistries()
```
If a caller passes a non-normalized plain object, it may be prototype-bearing and/or missing built-ins. A crafted lockfile registry name like `constructor` can then bypass `if (!namedRegistry)` fail-closed checks by resolving to an inherited truthy function.

### Issue Context
`normalizeNamedRegistries()` explicitly documents the need for a null-prototype map to prevent crafted dep-path names from resolving to `Object.prototype.*` and slipping past guards.

### Fix Focus Areas
- Change the verifier boundary to enforce normalization even when `opts.namedRegistries` is provided, e.g.:
 - `const mergedNamedRegistries = normalizeNamedRegistries(opts.namedRegistries as any)`
 - or a fast-path check + normalize if prototype is not null.
- Ensure the resulting map is null-prototype so property lookups cannot hit inherited keys.

- pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts[136-137]
- pnpm11/config/normalize-registries/src/index.ts[20-36]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


12. Named registries proto-unsafe ✓ Resolved 🐞 Bug ⛨ Security
Description
normalizeNamedRegistries() returns a normal object (inherits from Object.prototype) even though
Config explicitly allows consumers to index namedRegistries directly, reintroducing the known risk
where a crafted alias like "constructor"/"toString" can yield a truthy inherited value and bypass
fail-closed guards or crash when treated as a URL. This contradicts the codebase’s own security
rationale that alias maps derived from lockfile/config must be prototype-free.
Code

pnpm11/config/normalize-registries/src/index.ts[R33-37]

+export function normalizeNamedRegistries (namedRegistries?: Record<string, string>): NamedRegistries {
+  return {
+    ...BUILTIN_NAMED_REGISTRIES,
+    ...namedRegistries,
+  } as NamedRegistries
Relevance

● Weak

Similar proto-safety hardening for namedRegistries indexing (Object.hasOwn/avoid inherited props)
was definitely rejected in PR#13528.

PR-#13528

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new normalization helper constructs a prototype-bearing object but downstream code is explicitly
told it can index this map directly; other newly-added code documents that this is unsafe unless the
map is null-prototype, because lockfile/config-derived alias strings can otherwise resolve to
inherited Object.prototype members (e.g. constructor) and bypass if (!registry) checks or cause
misbehavior when treated as a URL.

pnpm11/config/normalize-registries/src/index.ts[20-38]
pnpm11/config/reader/src/Config.ts[254-264]
pnpm11/config/pick-registry-for-package/src/index.ts[26-41]
pnpm11/resolving/npm-resolver/src/index.ts[818-829]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`normalizeNamedRegistries()` currently returns a plain object created via object spread. That object inherits from `Object.prototype`, so property lookups can accidentally resolve inherited members (e.g. `constructor`, `toString`) instead of returning `undefined` for unknown aliases. This is explicitly called out elsewhere in the codebase as a security requirement: alias maps must be null-prototype to ensure unknown aliases fail closed.

### Issue Context
- `Config.namedRegistries` is documented as safe for direct indexing.
- `createKnownRegistries()` documents the precise exploit pattern if alias maps are not prototype-free.

### Fix
Change `normalizeNamedRegistries()` to return a null-prototype record, e.g.:

```ts
export function normalizeNamedRegistries (namedRegistries?: Record<string, string>): NamedRegistries {
 return Object.assign(
   Object.create(null) as NamedRegistries,
   BUILTIN_NAMED_REGISTRIES,
   namedRegistries,
 )
}
```

Then adjust any tests that use `toStrictEqual({...})` (which compares prototypes) to either:
- compare via `Object.entries(...)`, or
- assert `Object.getPrototypeOf(result) === null` plus value equality.

### Fix Focus Areas
- pnpm11/config/normalize-registries/src/index.ts[20-38]
- pnpm11/config/reader/test/index.ts[3856-3866]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


13. Missing trailing comma in Object.assign ⊘ Outdated 📘 Rule violation ⚙ Maintainability
Description
The new multi-line Object.assign(...) call omits a trailing comma after the last argument,
violating the TypeScript trailing-comma requirement and causing noisier diffs when adding/reordering
arguments.
Code

pnpm11/core/constants/src/index.ts[R75-78]

+    Object.create(null) as Record<string, string>,
+    BUILTIN_NAMED_REGISTRIES,
+    namedRegistries
+  )
Relevance

● Weak

Trailing-comma style findings repeatedly rejected in pnpm11 reviews (e.g., missing trailing commas
in multiline constructs).

PR-#13477
PR-#13289
PR-#13464

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in TypeScript multi-line constructs. In
createKnownRegistries(), the multi-line Object.assign(...) argument list ends with
namedRegistries without a trailing comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/core/constants/src/index.ts[75-78]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A multi-line argument list in TypeScript is missing a trailing comma on the last item.

## Issue Context
The repo’s compliance rule requires trailing commas in TypeScript multi-line constructs to keep diffs stable and consistent.

## Fix Focus Areas
- pnpm11/core/constants/src/index.ts[75-78]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/resolving-npm-resolver/src/named_registry.rs`:
- Around line 126-135: Make KnownRegistries::new fallible and validate every
built-in and supplied registry entry before inserting it into by_alias; reject
invalid aliases and non-HTTP(S) URLs using the existing validation/error types
rather than silently retaining raw data. Build both by_alias and
tarball_prefixes from the same validated registry set, and update
create_npm_resolution_verifier and any callers to propagate the construction
error instead of bypassing merge validation.

In `@pnpm/crates/resolving-npm-resolver/src/named_registry/tests.rs`:
- Line 63: Add an assertion in the existing KnownRegistries tarball-prefix test
covering two registry URLs with equal-length prefixes, and verify they are
ordered lexicographically. Keep the existing different-length coverage and
ensure the expected sequence demonstrates deterministic longest-prefix ordering
rather than HashMap iteration order.

In `@pnpm11/deps/compliance/sbom/src/collectComponents.ts`:
- Around line 216-218: Reuse one KnownRegistries instance per install: in
pnpm11/deps/compliance/sbom/src/collectComponents.ts lines 216-218, hoist
createKnownRegistries(opts.namedRegistries) to collectSbomComponents and pass
its byAlias through walkStep instead of rebuilding it per dependency; in
pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts line 52, extend
PkgSnapshotToResolutionOptions with an optional precomputed alias map or
KnownRegistries, using createKnownRegistries(opts.namedRegistries) only when
none is supplied, so collectComponents.ts can reuse the shared instance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e7304e70-277c-4079-9fa2-974590b9bc40

📥 Commits

Reviewing files that changed from the base of the PR and between 2d30dd6 and d89758f.

📒 Files selected for processing (11)
  • .changeset/known-registries-single-owner.md
  • pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier.rs
  • pnpm/crates/resolving-npm-resolver/src/lib.rs
  • pnpm/crates/resolving-npm-resolver/src/named_registry.rs
  • pnpm/crates/resolving-npm-resolver/src/named_registry/tests.rs
  • pnpm11/core/constants/src/index.ts
  • pnpm11/deps/compliance/sbom/src/collectComponents.ts
  • pnpm11/installing/deps-resolver/src/updateLockfile.ts
  • pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts
  • pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts
  • pnpm11/resolving/npm-resolver/test/knownRegistries.test.ts

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

github-actions Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     11.7±0.05ms    31.9 MB/sec    1.02     11.9±0.03ms    31.3 MB/sec
packument/parse                                  1.09     39.0±0.05µs  1701.2 MB/sec    1.00     35.9±0.06µs  1847.9 MB/sec
tarball/download_dependency                      1.01      2.3±0.06ms  1902.6 KB/sec    1.00      2.3±0.05ms  1921.9 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    170.9±2.12ms 93.6 KElem/sec    1.01    172.1±2.83ms 92.9 KElem/sec
workspace_resolution/hoist_heavy                 1.00    235.5±0.84ms        ? ?/sec    1.05    247.0±0.80ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Aug 2, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.99%. Comparing base (2d30dd6) to head (de065a4).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...npm-resolver/src/create_npm_resolution_verifier.rs 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13591      +/-   ##
==========================================
+ Coverage   87.98%   87.99%   +0.01%     
==========================================
  Files         565      567       +2     
  Lines       97856    97936      +80     
==========================================
+ Hits        86101    86182      +81     
+ Misses      11755    11754       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

`@pnpm/constants` holds constants. `createKnownRegistries` is a factory that
parses URLs, normalizes paths, sorts, and memoizes — none of which the
package name leads a reader to expect. `BUILTIN_NAMED_REGISTRIES` stays,
since that genuinely is one.

`@pnpm/config.pick-registry-for-package` is the natural home: its whole job
is deciding which registry a package comes from, and the known-registry set
is the input to that decision. Scope-based selection (`pickRegistryForPackage`)
and alias-based selection now sit together, which also matches pacquet, where
`KnownRegistries` already lives beside `pick_registry_for_package` and
`pick_registry_for_version` in `named_registry.rs`.

The pinning test moves with the code it covers.
Copilot AI review requested due to automatic review settings August 2, 2026 15:25

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Moved KnownRegistries out of @pnpm/constants (b585229) — that was the wrong home and the package name said so.

@pnpm/constants holds constants; createKnownRegistries parses URLs, normalizes paths, sorts, and memoizes. BUILTIN_NAMED_REGISTRIES stays there, since that genuinely is one.

It now lives in @pnpm/config.pick-registry-for-package, whose whole job is deciding which registry a package comes from — the known-registry set is the input to that decision. Scope-based selection (pickRegistryForPackage) and alias-based selection sit together now, which also brings the TypeScript layout in line with pacquet, where KnownRegistries already lives beside pick_registry_for_package and pick_registry_for_version in named_registry.rs. The pinning test moved with the code it covers.

Costs three new workspace deps (lockfile.utils, deps.compliance.sbom, installing.deps-resolver), all on a package that only depends on @pnpm/types and @pnpm/constants.

All suites re-run green after the move: pick-registry-for-package (10), npm-resolver (327), lockfile.utils (18), sbom (79), deps-resolver (176).


Written by an agent (Claude Code, claude-opus-5).

@coderabbitai coderabbitai Bot 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pnpm11/config/pick-registry-for-package/test/knownRegistries.test.ts (1)

37-47: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a deterministic tie-break test.

The test verifies descending prefix length only. It does not verify lexicographic ordering when two prefixes have equal length.

Add two same-length registry paths and assert their exact order. This protects the a < b ? -1 : a > b ? 1 : 0 contract.

Proposed test addition
 test('prefixes are ordered longest first so the deepest match wins', () => {
   const { tarballPrefixes } = createKnownRegistries({
     team: 'https://npm.example/team',
     teamSub: 'https://npm.example/team/sub',
+    tieA: 'https://npm.example/a',
+    tieB: 'https://npm.example/b',
   })
 
   const lengths = tarballPrefixes.map((prefix) => prefix.length)
   expect(lengths).toStrictEqual([...lengths].sort((a, b) => b - a))
   expect(tarballPrefixes.indexOf('https://npm.example/team/sub/'))
     .toBeLessThan(tarballPrefixes.indexOf('https://npm.example/team/'))
+  expect(tarballPrefixes.filter((prefix) =>
+    prefix === 'https://npm.example/a/' || prefix === 'https://npm.example/b/'
+  )).toStrictEqual([
+    'https://npm.example/a/',
+    'https://npm.example/b/',
+  ])
 })

As per path instructions, add focused tests for deterministic ties.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm11/config/pick-registry-for-package/test/knownRegistries.test.ts` around
lines 37 - 47, Add a focused test alongside “prefixes are ordered longest first
so the deepest match wins” using two registry paths with equal-length prefixes,
then assert the complete tarballPrefixes order matches lexicographic ascending
order. Keep the existing longest-prefix assertions unchanged and target the
ordering behavior implemented by createKnownRegistries.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@pnpm11/config/pick-registry-for-package/test/knownRegistries.test.ts`:
- Around line 37-47: Add a focused test alongside “prefixes are ordered longest
first so the deepest match wins” using two registry paths with equal-length
prefixes, then assert the complete tarballPrefixes order matches lexicographic
ascending order. Keep the existing longest-prefix assertions unchanged and
target the ordering behavior implemented by createKnownRegistries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b32ac90-1ab0-45ec-81e0-f1cf2acd3eb4

📥 Commits

Reviewing files that changed from the base of the PR and between d89758f and b585229.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (16)
  • .changeset/known-registries-single-owner.md
  • pnpm11/config/pick-registry-for-package/package.json
  • pnpm11/config/pick-registry-for-package/src/index.ts
  • pnpm11/config/pick-registry-for-package/test/knownRegistries.test.ts
  • pnpm11/config/pick-registry-for-package/tsconfig.json
  • pnpm11/core/constants/src/index.ts
  • pnpm11/deps/compliance/sbom/package.json
  • pnpm11/deps/compliance/sbom/src/collectComponents.ts
  • pnpm11/deps/compliance/sbom/tsconfig.json
  • pnpm11/installing/deps-resolver/package.json
  • pnpm11/installing/deps-resolver/src/updateLockfile.ts
  • pnpm11/installing/deps-resolver/tsconfig.json
  • pnpm11/lockfile/utils/package.json
  • pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts
  • pnpm11/lockfile/utils/tsconfig.json
  • pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts
💤 Files with no reviewable changes (1)
  • pnpm11/core/constants/src/index.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • .changeset/known-registries-single-owner.md
  • pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts
  • pnpm11/installing/deps-resolver/src/updateLockfile.ts
  • pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts
  • pnpm11/deps/compliance/sbom/src/collectComponents.ts

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit b585229

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

`createKnownRegistries` had no business knowing the built-ins. `registries`
already showed the right shape: `normalizeRegistries` fills in the defaults —
`@jsr` included — once at the boundary, and everything downstream just indexes
a complete map. `namedRegistries` skipped that step, so every consumer that
resolved an alias had to remember to merge the built-ins at lookup time.

`normalizeNamedRegistries` now sits beside `normalizeRegistries`, and the
config reader applies it where `registries` gets its defaults, so
`config.namedRegistries` arrives complete.

The risk in moving a merge from the lookup to the boundary is that it fails
open: miss one entry point and `gh:` and `npmjs:` silently stop resolving
there. So the guarantee is carried by the type, exactly as `Registries` does
it with its required `default`. `NamedRegistries` requires `gh` and `npmjs`,
which means a raw config map cannot reach a consumer without passing through
the normalizer, and a missed boundary is a compile error rather than a
runtime regression. Adding a built-in now means widening the type — the same
acknowledgement the reverse-routing prefix test asks for.

`Config.namedRegistries` stays optional. Making it required is the stronger
statement but it invalidates every hand-built `Config` in the test suite —
574 errors, almost all fixtures — for no gain the type does not already give
at the consumer boundary.

pacquet already had this shape: `merge_named_registries` is the normalizer
and runs at the entry points. Its verifier was the exception, taking the raw
user map and re-merging internally, so it now receives an already-merged one
like every other consumer.
Copilot AI review requested due to automatic review settings August 2, 2026 15:47

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Aug 2, 2026

Copy link
Copy Markdown
Member Author

Done in 17de458 — createKnownRegistries no longer knows about the built-ins.

registries already had the right shape and namedRegistries had simply skipped it: normalizeRegistries fills in the defaults (@jsr included) once at the boundary, and downstream code indexes a complete map. normalizeNamedRegistries now sits beside it, and the config reader applies it right where registries gets its defaults, so config.namedRegistries arrives complete.

How the fail-open risk is handled

Moving a merge from the lookup to the boundary fails open — miss one entry point and gh:/npmjs: silently stop resolving there. So the guarantee is carried by the type, the same way Registries does it with its required default:

export interface NamedRegistries {
  gh: string
  npmjs: string
  [alias: string]: string
}

A raw config map cannot reach a consumer without passing through the normalizer, so a missed boundary is a compile error rather than a runtime regression. Adding a built-in now means widening the type — the same acknowledgement the reverse-routing prefix test asks for.

The compiler found the boundaries for me: 21 option declarations retyped, and it pointed at exactly the four production call sites plus the test fixtures constructing partial maps.

One thing I did not do

Config.namedRegistries stays optional. Making it required is the stronger statement, and I tried it — it invalidates every hand-built Config across the test suite (574 errors, almost all fixtures) for no guarantee the type does not already provide at the consumer boundary. Not worth that churn in this PR.

pacquet

It already had this shape — merge_named_registries is the normalizer and runs at the entry points. Its verifier was the exception, taking the raw user map and re-merging internally; it now receives an already-merged one like every other consumer.

Verification

TypeScript: pick-registry-for-package (10), config.reader (323), npm-resolver (327), default-resolver (21), lockfile.utils (18), sbom (79), license-scanner (9), deps-resolver (176). Rust: 351 + 856, with fmt, clippy and rustdoc clean.

One behavioural note now pinned by a test: config.namedRegistries includes the built-ins, so the config-reader assertion that previously expected only the user entry was updated to reflect the new contract.


Written by an agent (Claude Code, claude-opus-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 17de458

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
pnpm/crates/package-manager/src/build_resolution_verifiers.rs (1)

113-118: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Remove the intermediate HashMap allocation.

KnownRegistries::new accepts a borrowed HashMap<String, String>. The current code clones every key and URL into a temporary map, then clones them again inside KnownRegistries::new. Pass &config.named_registries directly when the field uses the same map type.

Proposed simplification
-        named_registries: KnownRegistries::new(
-            &config
-                .named_registries
-                .iter()
-                .map(|(name, url)| (name.clone(), url.clone()))
-                .collect(),
-        )
+        named_registries: KnownRegistries::new(&config.named_registries)
            .into_by_alias(),

As per coding guidelines, choose borrowed parameters to minimize copies. As per path instructions, Rust registry code should prefer borrowed parameters unless ownership avoids copying.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/package-manager/src/build_resolution_verifiers.rs` around lines
113 - 118, Update the named_registries argument to KnownRegistries::new to pass
a reference to config.named_registries directly, removing the iterator, key/URL
clones, and temporary HashMap allocation while preserving the existing behavior.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/package-manager/src/build_resolution_verifiers.rs`:
- Around line 109-120: Validate every configured named registry URL and alias
while constructing Config or PackageManagerVerifierOptions, before the
named_registries map reaches KnownRegistries::new(...).into_by_alias() in build
resolution verification. Reuse merge_named_registries() or the existing
validation logic so malformed aliases and URLs are rejected consistently, while
preserving the verifier’s current registry merge behavior.

In `@pnpm11/config/reader/src/index.ts`:
- Around line 358-360: Move the normalizeNamedRegistries call out of the current
defaults setup and into the final Config-to-install-options normalization
section, after addSettingsFromWorkspaceManifestToConfig and all registry
overlays have been applied. Ensure the final namedRegistries map retains
built-in aliases such as gh and npmjs even when workspace settings replace the
merged value.

In `@pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts`:
- Line 53: Update pkgSnapshotToResolution and its callers so KnownRegistries is
constructed once by the owning resolver or traversal and passed through the
options for every snapshot resolution; replace the per-call
createKnownRegistries invocation and reuse the shared instance for
named-registry alias lookups across dependency, SBOM, license, inspection, and
hoisting flows.

---

Nitpick comments:
In `@pnpm/crates/package-manager/src/build_resolution_verifiers.rs`:
- Around line 113-118: Update the named_registries argument to
KnownRegistries::new to pass a reference to config.named_registries directly,
removing the iterator, key/URL clones, and temporary HashMap allocation while
preserving the existing behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 31a86033-8351-4762-b806-89b6122d47e7

📥 Commits

Reviewing files that changed from the base of the PR and between b585229 and 17de458.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (54)
  • .changeset/known-registries-single-owner.md
  • pnpm/crates/package-manager/src/build_resolution_verifiers.rs
  • pnpm/crates/resolving-npm-resolver/src/named_registry.rs
  • pnpm11/config/normalize-registries/package.json
  • pnpm11/config/normalize-registries/src/index.ts
  • pnpm11/config/normalize-registries/tsconfig.json
  • pnpm11/config/pick-registry-for-package/package.json
  • pnpm11/config/pick-registry-for-package/src/index.ts
  • pnpm11/config/pick-registry-for-package/test/knownRegistries.test.ts
  • pnpm11/config/pick-registry-for-package/tsconfig.json
  • pnpm11/config/reader/package.json
  • pnpm11/config/reader/src/Config.ts
  • pnpm11/config/reader/src/index.ts
  • pnpm11/config/reader/test/index.ts
  • pnpm11/config/reader/tsconfig.json
  • pnpm11/core/types/src/misc.ts
  • pnpm11/core/types/src/package.ts
  • pnpm11/deps/compliance/license-scanner/package.json
  • pnpm11/deps/compliance/license-scanner/src/getPkgInfo.ts
  • pnpm11/deps/compliance/license-scanner/src/licenses.ts
  • pnpm11/deps/compliance/license-scanner/src/lockfileToLicenseNodeTree.ts
  • pnpm11/deps/compliance/license-scanner/test/licenses.spec.ts
  • pnpm11/deps/compliance/license-scanner/tsconfig.json
  • pnpm11/deps/compliance/sbom/package.json
  • pnpm11/deps/compliance/sbom/src/collectComponents.ts
  • pnpm11/deps/compliance/sbom/test/collectComponents.test.ts
  • pnpm11/deps/compliance/sbom/tsconfig.json
  • pnpm11/deps/graph-builder/src/lockfileToDepGraph.ts
  • pnpm11/deps/inspection/list/src/index.ts
  • pnpm11/deps/inspection/tree-builder/src/buildDependenciesTree.ts
  • pnpm11/deps/inspection/tree-builder/src/buildDependentsTree.ts
  • pnpm11/deps/inspection/tree-builder/src/getPkgInfo.ts
  • pnpm11/deps/inspection/tree-builder/src/getTree.ts
  • pnpm11/installing/deps-installer/src/install/extendInstallOptions.ts
  • pnpm11/installing/deps-resolver/package.json
  • pnpm11/installing/deps-resolver/src/resolveDependencies.ts
  • pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts
  • pnpm11/installing/deps-resolver/src/updateLockfile.ts
  • pnpm11/installing/deps-resolver/tsconfig.json
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm11/installing/deps-restorer/src/lockfileToHoistedDepGraph.ts
  • pnpm11/lockfile/utils/package.json
  • pnpm11/lockfile/utils/src/pkgSnapshotToResolution.ts
  • pnpm11/lockfile/utils/test/pkgSnapshotToResolution.ts
  • pnpm11/lockfile/utils/tsconfig.json
  • pnpm11/resolving/default-resolver/package.json
  • pnpm11/resolving/default-resolver/test/namedRegistry.ts
  • pnpm11/resolving/default-resolver/tsconfig.json
  • pnpm11/resolving/npm-resolver/package.json
  • pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts
  • pnpm11/resolving/npm-resolver/src/index.ts
  • pnpm11/resolving/npm-resolver/test/createNpmResolutionVerifier.test.ts
  • pnpm11/resolving/npm-resolver/test/resolveNamedRegistry.test.ts
  • pnpm11/resolving/npm-resolver/tsconfig.json
🚧 Files skipped from review as they are similar to previous changes (11)
  • .changeset/known-registries-single-owner.md
  • pnpm11/deps/compliance/sbom/package.json
  • pnpm11/config/pick-registry-for-package/package.json
  • pnpm11/config/pick-registry-for-package/test/knownRegistries.test.ts
  • pnpm11/deps/compliance/sbom/tsconfig.json
  • pnpm11/config/pick-registry-for-package/tsconfig.json
  • pnpm11/lockfile/utils/tsconfig.json
  • pnpm11/installing/deps-resolver/src/updateLockfile.ts
  • pnpm11/resolving/npm-resolver/src/createNpmResolutionVerifier.ts
  • pnpm11/installing/deps-resolver/tsconfig.json
  • pnpm/crates/resolving-npm-resolver/src/named_registry.rs

Comment thread pnpm11/config/reader/src/index.ts Resolved
Copilot AI review requested due to automatic review settings August 2, 2026 16:52

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ec57bae

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

zkochan added 2 commits August 2, 2026 18:55
Verifier construction unwrapped `merge_named_registries` with `.expect()`,
so a reserved name or an unusable URL aborted the process instead of
reporting ERR_PNPM_RESERVED_NAMED_REGISTRY_NAME. Reachable on the ordinary
install path: `install.rs` builds verifiers before the resolver chain that
also validates, and on the frozen path that chain never runs at all.

The error now propagates through `BuildVerifiersError`, which the call site
already routes into `InstallError`. `#[diagnostic(transparent)]` keeps the
inner code, so the message a user sees is unchanged from the resolver path.

This also closes a gap that predates the PR: a frozen install with an
invalid `namedRegistries` previously reached no validation at all.
The dylint perfectionist rule rejects an inline `mod tests { ... }`.
Copilot AI review requested due to automatic review settings August 2, 2026 16:58

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 36672c8

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

A stray blank line at the top of core/types/src/package.ts, left by a
scripted import removal, and three `@pnpm/config.pick-registry-for-package`
dependencies that stopped being used when `createKnownRegistries` went away —
those callers only reach for `normalizeNamedRegistries` now. tsconfig
references regenerated with meta-updater to match.
Copilot AI review requested due to automatic review settings August 2, 2026 17:13

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit de065a4

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit 91d3c2e into main Aug 2, 2026
37 checks passed
@zkochan
zkochan deleted the known-registries branch August 2, 2026 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Give the known-registry set one owner, so adding a built-in alias can't silently change verification routing

3 participants