Skip to content

fix: preserve named catalog group during interactive upgrade --latest#11567

Merged
zkochan merged 1 commit into
pnpm:mainfrom
mcmxcdev:fix/10115
May 14, 2026
Merged

fix: preserve named catalog group during interactive upgrade --latest#11567
zkochan merged 1 commit into
pnpm:mainfrom
mcmxcdev:fix/10115

Conversation

@mcmxcdev

@mcmxcdev mcmxcdev commented May 10, 2026

Copy link
Copy Markdown
Member

When upgrading a dependency that uses a named catalog (e.g. "catalog:foo"), the previous specifier's catalog name now takes priority over the global saveCatalogName option. This prevents the package.json from being rewritten to "catalog:" and the updated version from landing in the default catalog instead of the named one.

Closes #10115

Summary by CodeRabbit

  • Bug Fixes
    • Fixed pnpm upgrade --interactive --latest -r to correctly preserve and respect named catalog groups (e.g., catalog:foo) when upgrading dependencies. Previously, named catalog entries would be incorrectly rewritten to use the default catalog instead of the specified named catalog.

Review Change Stack

When upgrading a dependency that uses a named catalog (e.g. "catalog:foo"),
the previous specifier's catalog name now takes priority over the global
saveCatalogName option. This prevents the package.json from being rewritten
to "catalog:" and the updated version from landing in the default catalog
instead of the named one.

Closes pnpm#10115

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented May 10, 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: d9b47284-10ad-48f3-b0e9-06a0cdc2ce34

📥 Commits

Reviewing files that changed from the base of the PR and between e1e29c1 and 6540df8.

📒 Files selected for processing (3)
  • .changeset/fix-named-catalog-upgrade.md
  • installing/deps-installer/src/install/index.ts
  • installing/deps-installer/test/catalogs.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)
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{js,ts,tsx,jsx}: Use trailing commas in code following Standard Style with modifications
Prefer functions over classes
Declare functions after they are used, relying on hoisting
Functions should have no more than two or three arguments; use a single options object for functions needing more parameters
Organize imports in order: standard libraries, external dependencies (sorted alphabetically), then relative imports

Files:

  • installing/deps-installer/src/install/index.ts
  • installing/deps-installer/test/catalogs.ts
🔇 Additional comments (5)
.changeset/fix-named-catalog-upgrade.md (1)

1-7: LGTM!

The changeset correctly documents the fix with a clear description and proper issue reference.

installing/deps-installer/src/install/index.ts (2)

1101-1120: LGTM!

The getPerDepCatalogName helper correctly extracts the catalog name from the previous specifier when present, ensuring named catalog groups like catalog:foo are preserved during interactive updates and --latest upgrades. The fallback chain to globalSaveCatalogName and then 'default' handles all edge cases appropriately.


715-728: LGTM!

The integration correctly computes per-dependency catalog names before resolution, constructs the appropriate bare specifier format, and conditionally sets saveCatalogName only when the catalog should be used.

installing/deps-installer/test/catalogs.ts (2)

1758-1812: LGTM!

Excellent test coverage for the named catalog upgrade scenario. The test correctly verifies that:

  1. The manifest preserves the catalog:foo specifier (not rewritten to catalog:)
  2. The updatedCatalogs contains updates to the foo catalog (not default)
  3. The lockfile reflects the updated version in the correct catalog

1814-1869: LGTM!

Good additional coverage for catalogMode: 'prefer'. This ensures the named catalog preservation works consistently across different catalog modes.


📝 Walkthrough

Walkthrough

This PR fixes named catalog group preservation during pnpm upgrade --interactive --latest -r. Previously, dependencies like "@sanity/client": "catalog:sanity" were incorrectly rewritten to "catalog:" with the upgrade applied to the default catalog instead of the named catalog. The fix computes catalog names per dependency, extracting them from previous specifiers to preserve named catalog references during updates.

Changes

Named Catalog Upgrade Preservation

Layer / File(s) Summary
Changelog Entry
.changeset/fix-named-catalog-upgrade.md
Documents the patch fix for pnpm upgrade --interactive --latest -r preserving named catalog references like catalog:foo instead of rewriting to catalog:.
Catalog Name Resolution
installing/deps-installer/src/install/index.ts
New getPerDepCatalogName helper extracts the catalog name from a dependency's previous specifier, falling back to the global catalog name if no named catalog is present.
Installation Logic
installing/deps-installer/src/install/index.ts
Modified installSome flow to compute the effective catalog name per dependency before resolving catalog specifiers, updating saveCatalogName per dependency instead of using a global value.
Test Coverage
installing/deps-installer/test/catalogs.ts
Two new tests verify update --latest preserves catalog:foo specifiers in manifests while updating the named catalog entry to the latest version in lockfile catalogs and snapshots, with and without catalogMode: 'prefer'.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

area: catalogs

Suggested reviewers

  • zkochan

Poem

🐰 A catalog named foo, once lost in the fray,
Now keeps its true name when upgrades hold sway,
Per-dependency wisdom guides each package's way,
Named catalogs bloom and no longer stray!
The lockfile rejoices, the manifest stays bright,
With named catalogs shining—the fix is just right! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 clearly describes the main fix: preserving named catalog groups during interactive upgrade with --latest flag, matching the core change in the code.
Linked Issues check ✅ Passed The PR comprehensively addresses issue #10115 by fixing the catalog name selection logic to use per-dependency catalog names instead of global saveCatalogName, preventing incorrect rewrites to unnamed catalogs.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing issue #10115: the changelog entry, the installation logic changes, and new test coverage for named catalog upgrades. No unrelated modifications detected.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

@mcmxcdev mcmxcdev marked this pull request as ready for review May 10, 2026 01:02
@mcmxcdev mcmxcdev requested a review from zkochan as a code owner May 10, 2026 01:02
@zkochan zkochan merged commit 8c06d1a into pnpm:main May 14, 2026
9 checks passed
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.

pnpm upgrade --interactive --latest -r doesn't respect named catalog groups

2 participants