Skip to content

fix(config/reader): only sync registries.default to registry when workspace contributes it#11754

Merged
zkochan merged 1 commit into
mainfrom
fix/config-registry-sync-npmrc
May 19, 2026
Merged

fix(config/reader): only sync registries.default to registry when workspace contributes it#11754
zkochan merged 1 commit into
mainfrom
fix/config-registry-sync-npmrc

Conversation

@zkochan

@zkochan zkochan commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

  • Restricts the registries.defaultpnpmConfig.registry sync introduced in fix: synchronize default registry from pnpm-workspace.yaml for login/logout commands #11744 to cases where pnpm-workspace.yaml actually contributes a default different from what .npmrc provided.
  • Previously the sync also overwrote the unnormalized registry value parsed straight from .npmrc with the normalized form (with a trailing slash), causing config.registry to gain an unexpected trailing slash whenever a user set registry = … in .npmrc.

Repro

The test config/reader/test/index.ts: "getConfig() returns the userconfig even when overridden locally" started failing on main:

Expected: "https://project-local.example.test"
Received: "https://project-local.example.test/"

The user has registry = https://project-local.example.test in .npmrc, no pnpm-workspace.yaml, and the new sync fired anyway because registry wasn't on the CLI.

Test plan

  • config.registry stays unnormalized when only .npmrc provides it (existing test re-passes).
  • pnpm-workspace.yaml registries.default still flows into config.registry (covered by "pnpm-workspace.yaml registries.default is reflected in config.registry (#10099)").
  • CLI --registry still wins over both (covered by "CLI --registry overrides pnpm-workspace.yaml registries.default (#10099)").

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

Summary by CodeRabbit

  • Bug Fixes
    • Fixed workspace configuration syncing to prevent unnecessary modifications to registry settings when using .npmrc without explicit workspace manifest defaults.

Review Change Stack

…kspace contributes it

The sync introduced in #11744 unconditionally overwrote the unnormalized
registry value parsed from .npmrc with the normalized registries.default,
causing a trailing slash to appear in config.registry when the user only
configured a registry in .npmrc.

Restrict the sync to cases where pnpm-workspace.yaml actually contributes
a default registry different from what .npmrc provided.
Copilot AI review requested due to automatic review settings May 19, 2026 22:49
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dc2f7b0a-eb94-4dd3-9908-7166ce55c078

📥 Commits

Reviewing files that changed from the base of the PR and between 3687b0e and d326bf5.

📒 Files selected for processing (2)
  • .changeset/config-reader-registry-sync-npmrc.md
  • config/reader/src/index.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Compile & Lint
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Follow Standard Style with trailing commas, prefer functions over classes, declare functions after they are used (rely on hoisting), and use a single options object for functions with more than two or three arguments
Sort imports in three groups: standard libraries, external dependencies (alphabetically), then relative imports
Write code that explains itself through clear naming and types — do not write comments that merely restate what the code already says; use comments only for non-obvious reasons, hidden invariants, or workarounds

Files:

  • config/reader/src/index.ts
🧠 Learnings (1)
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • config/reader/src/index.ts
🔇 Additional comments (2)
config/reader/src/index.ts (1)

466-470: LGTM!

.changeset/config-reader-registry-sync-npmrc.md (1)

1-6: LGTM!


📝 Walkthrough

Walkthrough

This PR tightens the conditions for syncing the workspace registry default to the top-level config. When .npmrc sets config.registry but pnpm-workspace.yaml provides no registries.default, pnpm now skips the sync, avoiding unwanted trailing-slash appending.

Changes

Registry Default Sync Conditions

Layer / File(s) Summary
Registry sync condition tightening
config/reader/src/index.ts, .changeset/config-reader-registry-sync-npmrc.md
The sync from pnpmConfig.registries.default to pnpmConfig.registry is now conditional on the workspace manifest actually providing a different default than .npmrc, in addition to CLI not explicitly overriding it. A changesets entry documents the refined behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • pnpm/pnpm#11744: Introduced the initial gating of registries.defaultregistry sync in getConfig; this PR tightens the condition further by comparing workspace and .npmrc defaults.
  • pnpm/pnpm#11494: Adjusts how pnpm derives registry URLs from .npmrc vs pnpm-workspace.yaml for config consistency; this PR refines a related sync condition in the config reader.

Suggested labels

area: cli/dlx


🐰 A trailing slash in the night,
Made the workspace sync less bright—
Now we check if change is real,
Before we sync with zealous zeal!
Config harmony restored with care,
Registry defaults, clean and fair. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: restricting the sync of registries.default to registry to only occur when workspace contributes a different default, which is the core fix in this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/config-registry-sync-npmrc

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 and usage tips.

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.

Pull request overview

Fixes a regression from #11744 where pnpm-workspace.yamlconfig.registry sync also overwrote the unnormalized registry value from .npmrc with a normalized (trailing-slash) form, even when the workspace manifest didn't contribute a default. The sync now only fires when the post-merge registries.default differs from the npmrc-derived default.

Changes:

  • Tighten the condition for syncing registries.defaultpnpmConfig.registry to require a workspace-contributed difference.
  • Add a changeset describing the bug fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
config/reader/src/index.ts Adds pnpmConfig.registries.default !== registriesFromNpmrc.default guard to the registry sync.
.changeset/config-reader-registry-sync-npmrc.md Patch changeset for @pnpm/config.reader and pnpm.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zkochan zkochan merged commit ced20cb into main May 19, 2026
16 checks passed
@zkochan zkochan deleted the fix/config-registry-sync-npmrc branch May 19, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants