Skip to content

fix: allow global named registries config - #12862

Merged
zkochan merged 5 commits into
pnpm:mainfrom
ychampion:fix-global-named-registries
Jul 9, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
ychampion:fix-global-named-registries

Conversation

@ychampion

@ychampion ychampion commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Allows registries and namedRegistries in the global config.yaml allowlist (TypeScript CLI and pacquet).
  • Preserves global YAML registries through the registry merge path, below _auth and CLI overrides.
  • Makes pnpm config set --global registries/named-registries succeed instead of erroring with an unsupported-key error, in both stacks.
  • Adds config reader, config set, precedence, and security regression coverage.

Fixes #12858.

Validation

TypeScript CLI:

  • pnpm --filter @pnpm/config.commands test test/configSet.test.ts
  • pnpm --filter @pnpm/config.reader test test/index.ts
  • pnpm --filter @pnpm/config.commands lint / pnpm --filter @pnpm/config.reader lint

pacquet:

  • cargo nextest run -p pacquet-config -p pacquet-cli
  • cargo clippy --locked -p pacquet-config -p pacquet-cli --all-targets -- --deny warnings
  • cargo fmt -p pacquet-config -p pacquet-cli -- --check

Squash Commit Body

Allow global config.yaml to carry registries and namedRegistries.

pnpm already parses those fields from YAML settings, but the global config
allowlist filtered them out and pnpm config set --global rejected them. That
leaves global installs unable to resolve named registry aliases.

Add registries/named-registries to the global YAML key allowlist, preserve
global YAML registries through the registry merge path (below _auth and CLI),
and make pnpm config set --global accept them. Mirror the same fix in pacquet
so both stacks stay behaviorally identical.

Add config set, reader, precedence, and security-regression coverage — the
latter asserting a global registry alias cannot rebind an _auth token's host.

Fixes pnpm/pnpm#12858.

Checklist

  • TypeScript CLI updated and mirrored in pacquet/ (config-file key allowlist and config set validation), so both stacks stay in sync.
  • 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.
  • Documentation is not needed; the behavior is covered by tests and the changeset.

Summary by CodeRabbit

  • New Features
    • You can now configure registries and namedRegistries in the global config.yaml file.
  • Bug Fixes
    • Improved merging and precedence of registry settings from global config, workspace manifests, and command-line inputs.
    • Expanded support for structured workspace/global config keys used for registries and named-registries.
    • Prevented global registries settings from redirecting _auth token routing unexpectedly.
  • Tests
    • Added coverage for loading/persisting registries/namedRegistries and verifying precedence and security behavior.

@ychampion
ychampion requested a review from zkochan as a code owner July 9, 2026 02:04
Copilot AI review requested due to automatic review settings July 9, 2026 02:04
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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 Jul 9, 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

Adds global config.yaml support for registries and namedRegistries, updates key validation and registry merging, and adds tests plus release metadata.

Changes

Global registries config support

Layer / File(s) Summary
Structured config key recognition
pnpm11/config/reader/src/configFileKey.ts, pacquet/crates/config/src/config_types.rs, pnpm11/config/commands/src/configSet.ts, pacquet/crates/cli/src/cli_args/config.rs
Adds structured YAML config keys and updates config-set validation to accept them.
Registry merge precedence
pnpm11/config/reader/src/index.ts, pnpm11/config/reader/test/index.ts
Captures registry values from global YAML and workspace manifests, then re-merges them into the final registry map; adds tests for loading global config.yaml registries and workspace precedence.
Config set and release metadata
pnpm11/config/commands/test/configSet.test.ts, pacquet/crates/cli/src/cli_args/config/tests.rs, .changeset/global-registries-config.md
Adds global config-set tests for registries and named-registries, and a changeset for the release.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant getConfig
  participant npmrc
  participant global config.yaml
  participant workspace manifest
  participant pnpmConfig

  getConfig->>npmrc: read registriesFromNpmrc
  getConfig->>global config.yaml: apply global YAML settings
  global config.yaml-->>getConfig: globalYamlRegistries
  getConfig->>workspace manifest: read manifest registries
  workspace manifest-->>getConfig: workspaceManifestRegistries
  getConfig->>pnpmConfig: merge registries and apply auth/CLI-scoped entries
Loading

Assessment against linked issues

Objective Addressed Explanation
Allow namedRegistries and registries to be set in global config.yaml [#12858] ✅
pnpm config set --json namedRegistries ... should succeed globally without ERR_PNPM_CONFIG_SET_UNSUPPORTED_YAML_CONFIG_KEY [#12858] ✅
Global installs using named-registry specifiers should resolve correctly [#12858] ✅

Possibly related PRs

  • pnpm/pnpm#11494: Also adjusts merged Config.registries handling used by registry resolution.
  • pnpm/pnpm#11754: Also modifies getConfig() registry merge behavior in pnpm11/config/reader/src/index.ts.
  • pnpm/pnpm#12559: Also changes registry routing and auth-related registry handling in the same config reader pipeline.

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

Suggested reviewers: zkochan, KSXGitHub

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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

🧹 Nitpick comments (1)
pnpm11/config/reader/test/index.ts (1)

3583-3615: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider adding a precedence test for workspace manifest vs global YAML registries.

The current test verifies global YAML registries override npmrc defaults, but doesn't cover the case where both global config.yaml and a workspace pnpm-workspace.yaml define registries — the workspace manifest should win. Adding such a test would fully satisfy the REVIEW_GUIDE.md expectation of asserting "correct precedence."

🤖 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/reader/test/index.ts` around lines 3583 - 3615, Add a
precedence test in the existing config reader test suite to cover the case where
both global config.yaml and pnpm-workspace.yaml define registries, and assert
that the workspace manifest values win over the global YAML values. Reuse the
existing getConfig setup and the registries/namedRegistries assertions so the
new test clearly contrasts global config versus workspace manifest precedence.
🤖 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.

Nitpick comments:
In `@pnpm11/config/reader/test/index.ts`:
- Around line 3583-3615: Add a precedence test in the existing config reader
test suite to cover the case where both global config.yaml and
pnpm-workspace.yaml define registries, and assert that the workspace manifest
values win over the global YAML values. Reuse the existing getConfig setup and
the registries/namedRegistries assertions so the new test clearly contrasts
global config versus workspace manifest precedence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f323b70d-61a1-46e2-9b20-d16d092cf5c6

📥 Commits

Reviewing files that changed from the base of the PR and between 508b8c2 and c839e54.

📒 Files selected for processing (6)
  • .changeset/global-registries-config.md
  • pnpm11/config/commands/src/configSet.ts
  • pnpm11/config/commands/test/configSet.test.ts
  • pnpm11/config/reader/src/configFileKey.ts
  • pnpm11/config/reader/src/index.ts
  • pnpm11/config/reader/test/index.ts

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 9, 2026
@zkochan
zkochan force-pushed the fix-global-named-registries branch from c839e54 to e92adc7 Compare July 9, 2026 12:12
Cover the precedence case where both the global config.yaml and a
pnpm-workspace.yaml define registries, asserting the workspace manifest
value wins while a scope present only in the global YAML still resolves.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 12:17

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

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to 24b1ddb

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Snapshot registry precedence layers

Create defensive copies of pnpmConfig.registries instead of storing object
references.

pnpm11/config/reader/src/index.ts [330-487]

-globalYamlRegistries = pnpmConfig.registries as Record<string, string> | undefined
+globalYamlRegistries = pnpmConfig.registries == null
+  ? undefined
+  : { ...(pnpmConfig.registries as Record<string, string>) }
 ...
-workspaceManifestRegistries = pnpmConfig.registries as Record<string, string> | undefined
+workspaceManifestRegistries = pnpmConfig.registries == null
+  ? undefined
+  : { ...(pnpmConfig.registries as Record<string, string>) }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 4

__

Why: While creating defensive copies of configuration objects can prevent unexpected mutation bugs, the current spread operation order likely handles references correctly without the extra allocation.

Low
General
Avoid unsupported global keys

Ensure named-registries has full parity in the Rust reader before including it
in the allowlist, and remove it if unsupported.

pacquet/crates/config/src/config_types.rs [313]

-const STRUCTURED_CONFIG_FILE_KEYS: &[&str] = &["named-registries", "registries"];
+const STRUCTURED_CONFIG_FILE_KEYS: &[&str] = &["registries"];
  • Apply / Chat
Suggestion importance[1-10]: 2

__

Why: The suggestion asks to verify the implementation of named-registries in the reader without concrete evidence of a bug, which is speculative since the PR explicitly intends to support both keys.

Low
  • More

Previous suggestions

Suggestions up to commit 2998fe7
CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve registry precedence

Reorder the merging of registry configurations to apply .npmrc settings after
global config.yaml values. This ensures the correct precedence where
project-local configurations override global ones.

pnpm11/config/reader/src/index.ts [306-507]

+const registriesFromNpmrc = {
+  default: normalizeRegistryUrl(pnpmConfig.authConfig.registry),
+  ...registryKeysFromConfig(pnpmConfig.authConfig),
+}
+
 let globalYamlRegistries: Record<string, string> | undefined
 // Reuse the global config.yaml already read for npmrcAuthFile
 const globalYamlConfig = globalYamlConfigForNpmrcAuthFile
 if (globalYamlConfig) {
   // Consumed by loadNpmrcConfig above; drop so it isn't flagged as unknown.
   ...
   addSettingsFromWorkspaceManifestToConfig(pnpmConfig, {
     configFromCliOpts,
     expandRequestDestinationEnv: true,
     projectManifest: undefined,
     workspaceDir: undefined,
     workspaceManifest: globalYamlConfig,
   })
   globalYamlRegistries = pnpmConfig.registries as Record<string, string> | undefined
 }
 const networkConfigs = getNetworkConfigs(pnpmConfig.authConfig)
-const registriesFromNpmrc = {
-  default: normalizeRegistryUrl(pnpmConfig.authConfig.registry),
-  ...registryKeysFromConfig(pnpmConfig.authConfig),
-}
 ...
 pnpmConfig.registries = {
+  ...globalYamlRegistries,
   ...registriesFromNpmrc,
-  ...globalYamlRegistries,
   ...workspaceManifestRegistries,
   // `_auth` routes win over repo-controlled yaml on conflicting scopes.
   ...npmrcResult.jsonAuth.registries,
   // CLI per-scope registries last, so `--@scope:registry=...` wins over
   // both yaml and `_auth` ("CLI > _auth > yaml").
   ...cliScopedRegistries(cliOptions),
 }
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies and fixes a configuration precedence bug, ensuring that global config.yaml registries do not mistakenly override project-level .npmrc registry settings.

High
Suggestions up to commit c08c15b
CategorySuggestion                                                                                                                                    Impact
Possible issue
Snapshot source-specific registry maps

Create shallow copies of pnpmConfig.registries when assigning to local
variables.

pnpm11/config/reader/src/index.ts [330-487]

-globalYamlRegistries = pnpmConfig.registries as Record<string, string> | undefined
+globalYamlRegistries = pnpmConfig.registries == null
+  ? undefined
+  : { ...(pnpmConfig.registries as Record<string, string>) }
 ...
-workspaceManifestRegistries = pnpmConfig.registries as Record<string, string> | undefined
+workspaceManifestRegistries = pnpmConfig.registries == null
+  ? undefined
+  : { ...(pnpmConfig.registries as Record<string, string>) }
Suggestion importance[1-10]: 2

__

Why: The suggestion proposes defensive copying which is unnecessary in this context, as pnpmConfig.registries is typically overwritten with distinct objects from each configuration source.

Low
Suggestions
CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve project registry precedence

Apply globalYamlRegistries before .npmrc-derived registries to preserve
project-level precedence.

pnpm11/config/reader/src/index.ts [498-505]

 pnpmConfig.registries = {
+  ...globalYamlRegistries,
   ...registriesFromNpmrc,
-  ...globalYamlRegistries,
   ...workspaceManifestRegistries,
   // `_auth` routes win over repo-controlled yaml on conflicting scopes.
   ...npmrcResult.jsonAuth.registries,
   // CLI per-scope registries last, so `--@scope:registry=...` wins over
   // both yaml and `_auth` ("CLI > _auth > yaml").
Suggestion importance[1-10]: 8

__

Why: This prevents a user-level global configuration from improperly overriding project-level local configurations, ensuring correct registry precedence.

Medium

@qodo-code-review

qodo-code-review Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 51 rules

Grey Divider


Action required

1. XDG_CONFIG_HOME env leak ✓ Resolved 🐞 Bug ☼ Reliability ⭐ New
Description
The new test sets process.env.XDG_CONFIG_HOME but never restores it, so subsequent tests in the same
Jest process may read global config from an unintended directory and become order-dependent. This
can also poison later save/restore logic that snapshots the current env value and re-applies the
leaked value in afterEach.
Code

pnpm11/config/reader/test/index.ts[R1388-1389]

+  process.env.XDG_CONFIG_HOME = path.resolve('.config')
+
Evidence
The new test sets process.env.XDG_CONFIG_HOME but does not restore it. Elsewhere in the same file,
tests and a describe('global config.yaml') block explicitly snapshot and restore
XDG_CONFIG_HOME, which will capture/reapply the leaked value if it remains set, making later tests
order-dependent.

pnpm11/config/reader/test/index.ts[1378-1409]
pnpm11/config/reader/test/index.ts[1067-1091]
pnpm11/config/reader/test/index.ts[3549-3568]

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 new Jest test mutates `process.env.XDG_CONFIG_HOME` and does not restore it. Because `process.env` is shared across tests in the same worker, this leaks state and can make unrelated tests read the wrong global `config.yaml` or restore the leaked value later.

### Issue Context
This file already uses a save/restore pattern (`try/finally` or `beforeEach/afterEach`) for `XDG_CONFIG_HOME` in other tests/describe blocks, indicating test isolation is expected.

### Fix Focus Areas
- pnpm11/config/reader/test/index.ts[1378-1410]

### Suggested fix
Wrap the `process.env.XDG_CONFIG_HOME = ...` assignment in a save/restore guard:
- capture `const originalXdg = process.env.XDG_CONFIG_HOME`
- set `process.env.XDG_CONFIG_HOME = ...`
- `try { ... } finally { restore original value or delete }`
Optionally also ensure any created `.config/` directory is scoped to the test workspace (or removed) to avoid interacting with later tests if the env is ever reintroduced.

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



Remediation recommended

2. Redundant doc comment on test 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The new Rust test’s doc comment restates the same scenario and outcome that the test name and
assertions already communicate, duplicating the explanation in both prose and code. This increases
maintenance burden because future refactors of the assertions would require keeping the narrative
comment in sync.
Code

pacquet/crates/config/src/tests.rs[R695-700]

+/// End-to-end: a `registries` alias in the user's global `config.yaml`
+/// cannot rebind a `pnpm_config__auth` token to a different host. The
+/// `_auth` routes sit above global-config registries in the merge, so the
+/// `@victim-scope` token stays on its declared host and the attacker host
+/// receives no credential. Mirrors the reader test
+/// `global config.yaml registries cannot redirect pnpm_config__auth routes`.
Evidence
The test doc comment describes the exact scenario (global registries alias attempting to redirect
pnpm_config__auth tokens) and the expected outcome (attacker host receives no credential), which
is already enforced by the subsequent assertions in the same test.

Rule 713470: Avoid duplicating test scenario explanations in both code and doc comments
pacquet/crates/config/src/tests.rs[695-700]

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 new test has a long `///` doc comment that largely duplicates what the test already asserts.

## Issue Context
Rule 713470 asks to avoid duplicating scenario explanations in both comments/doc comments and tests. Here, the doc comment repeats the attacker/victim host and credential-leak expectations that are already asserted in the test body.

## Fix Focus Areas
- pacquet/crates/config/src/tests.rs[695-700]

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


3. Structured keys allow scalars 🐞 Bug ☼ Reliability
Description
pnpm config set --global registries|named-registries can still be executed without --json, which
will write a scalar string into config.yaml for these structured settings. The config reader later
assumes config.registries is an object (spreads and indexes it), so a scalar value can corrupt
registry routing or cause confusing failures.
Code

pnpm11/config/commands/src/configSet.ts[R197-199]

+  if (Object.hasOwn(types, key) || isConfigFileKey(key)) return camelCase(key)
  if (!isCamelCase(key)) throw new ConfigSetUnsupportedWorkspaceKeyError(key)
  return key
Evidence
The changed validation allows these structured keys to be written, but the write path does not
enforce object typing for them, while the read path assumes an object and merges/indexes it as such.

pnpm11/config/commands/src/configSet.ts[18-63]
pnpm11/config/commands/src/configSet.ts[87-118]
pnpm11/config/commands/src/configSet.ts[191-200]
pnpm11/config/reader/src/index.ts[493-521]
pnpm11/config/pick-registry-for-package/src/index.ts[1-6]

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

## Issue description
The newly-allowed structured config keys (`registries`, `named-registries`) can be written via `pnpm config set --global` without `--json`, causing them to be persisted as scalar strings in YAML. The reader later treats these settings as objects and merges them with object spread, which can break registry selection.

## Issue Context
- `validateWorkspaceKey()` now accepts any `isConfigFileKey(key)` and then camelCases it.
- `castField()` only type-casts based on `types[...]`; structured keys are not in `types`, so non-`--json` writes will remain strings.

## Fix Focus Areas
- pnpm11/config/commands/src/configSet.ts[18-85]
- pnpm11/config/commands/src/configSet.ts[87-118]
- pnpm11/config/commands/src/configSet.ts[191-200]

## Suggested fix
1. Detect when the target key is a structured key (`registries` / `named-registries`), ideally before `validateWorkspaceKey()` converts it.
2. If `opts.json` is false and the value is non-null, throw a dedicated error (e.g. `CONFIG_SET_JSON_REQUIRED`) instructing the user to pass `--json`.
3. Optionally validate that the parsed value is a plain object whose values are strings, and error otherwise (this prevents accidentally writing arrays/numbers that will later break registry resolution).

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


Grey Divider

Previous review results

Review updated until commit 24b1ddb

Results up to commit 989617b


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Structured keys allow scalars 🐞 Bug ☼ Reliability
Description
pnpm config set --global registries|named-registries can still be executed without --json, which
will write a scalar string into config.yaml for these structured settings. The config reader later
assumes config.registries is an object (spreads and indexes it), so a scalar value can corrupt
registry routing or cause confusing failures.
Code

pnpm11/config/commands/src/configSet.ts[R197-199]

+  if (Object.hasOwn(types, key) || isConfigFileKey(key)) return camelCase(key)
  if (!isCamelCase(key)) throw new ConfigSetUnsupportedWorkspaceKeyError(key)
  return key
Evidence
The changed validation allows these structured keys to be written, but the write path does not
enforce object typing for them, while the read path assumes an object and merges/indexes it as such.

pnpm11/config/commands/src/configSet.ts[18-63]
pnpm11/config/commands/src/configSet.ts[87-118]
pnpm11/config/commands/src/configSet.ts[191-200]
pnpm11/config/reader/src/index.ts[493-521]
pnpm11/config/pick-registry-for-package/src/index.ts[1-6]

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

## Issue description
The newly-allowed structured config keys (`registries`, `named-registries`) can be written via `pnpm config set --global` without `--json`, causing them to be persisted as scalar strings in YAML. The reader later treats these settings as objects and merges them with object spread, which can break registry selection.

## Issue Context
- `validateWorkspaceKey()` now accepts any `isConfigFileKey(key)` and then camelCases it.
- `castField()` only type-casts based on `types[...]`; structured keys are not in `types`, so non-`--json` writes will remain strings.

## Fix Focus Areas
- pnpm11/config/commands/src/configSet.ts[18-85]
- pnpm11/config/commands/src/configSet.ts[87-118]
- pnpm11/config/commands/src/configSet.ts[191-200]

## Suggested fix
1. Detect when the target key is a structured key (`registries` / `named-registries`), ideally before `validateWorkspaceKey()` converts it.
2. If `opts.json` is false and the value is non-null, throw a dedicated error (e.g. `CONFIG_SET_JSON_REQUIRED`) instructing the user to pass `--json`.
3. Optionally validate that the parsed value is a plain object whose values are strings, and error otherwise (this prevents accidentally writing arrays/numbers that will later break registry resolution).

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


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Preserve project registry precedence

Apply globalYamlRegistries before .npmrc-derived registries to preserve
project-level precedence.

pnpm11/config/reader/src/index.ts [498-505]

 pnpmConfig.registries = {
+  ...globalYamlRegistries,
   ...registriesFromNpmrc,
-  ...globalYamlRegistries,
   ...workspaceManifestRegistries,
   // `_auth` routes win over repo-controlled yaml on conflicting scopes.
   ...npmrcResult.jsonAuth.registries,
   // CLI per-scope registries last, so `--@scope:registry=...` wins over
   // both yaml and `_auth` ("CLI > _auth > yaml").

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: This prevents a user-level global configuration from improperly overriding project-level local configurations, ensuring correct registry precedence.

Medium
  • More

Mirror the TypeScript fix so `pnpm config set --global registries` and
`--global named-registries` are accepted instead of rejected with an
unsupported-key error.

pacquet already reads these structured settings from the global config.yaml
via its typed workspace-manifest struct, but the config-file key allowlist
omitted them: is_config_file_key filtered them out (so validate_yaml_config_key
rejected them) and validate_workspace_key could not camelCase the hyphenated
named-registries key.

Add registries/named-registries to the config-file key allowlist and let
validate_workspace_key accept config-file keys, matching structuredConfigFileKeys
and validateWorkspaceKey in the TypeScript stack.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 12:39

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.

…th tokens

Lock in the security-relevant merge ordering added by this change: global
config.yaml registries sit below `_auth` routes, so a user's global registry
alias cannot rebind an `_auth`-bound token's host. A repo that overrides such a
scope receives no credential because tokens stay host-bound.

Covers the new global-config path in both stacks, mirroring the existing
repo-controlled `pnpm-workspace.yaml` redirect tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@qodo-code-review

Copy link
Copy Markdown

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

Copilot AI review requested due to automatic review settings July 9, 2026 12: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.

Comment thread pnpm11/config/reader/test/index.ts Resolved
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2998fe7

@codecov-commenter

codecov-commenter commented Jul 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.32%. Comparing base (388001c) to head (24b1ddb).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12862   +/-   ##
=======================================
  Coverage   85.32%   85.32%           
=======================================
  Files         451      451           
  Lines       70701    70705    +4     
=======================================
+ Hits        60323    60329    +6     
+ Misses      10378    10376    -2     

☔ 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.

The global-config redirect test set process.env.XDG_CONFIG_HOME without
restoring it, which could make later tests in the same Jest worker read an
unintended global config directory. getConfig already resolves the config dir
from its env option, so pass XDG_CONFIG_HOME there instead of mutating the
shared process environment.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 9, 2026 13:19

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 24b1ddb

@zkochan
zkochan merged commit 9318a11 into pnpm:main Jul 9, 2026
32 checks passed
@welcome

welcome Bot commented Jul 9, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

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.

Can't define namedRegistries globally

4 participants