Skip to content

fix(catalogs): preserve valid resolutions during dedupe - #13468

Merged
zkochan merged 2 commits into
mainfrom
fix-13465
Jul 28, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-13465

Conversation

@zkochan

@zkochan zkochan commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes pnpm dedupe so a catalog version already recorded in the lockfile remains selected while it satisfies the catalog range, even when a newer matching version is also present.

The dedupe pass still rebuilds importer and package dependency edges, but it no longer discards the catalog snapshot that provides the catalog-specific preferred version. Pacquet already preserves this valid pin, so no Rust change is needed.

Closes #13465.

Squash Commit Body

Keep catalog snapshots available while dedupe rebuilds importer and package dependency edges. The resolver validates that the recorded catalog specifier still matches before reusing its version, so changed catalog ranges continue to re-resolve while valid pins remain stable.

Closes pnpm/pnpm#13465.

Checklist

  • 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 (Codex, GPT-5.6).


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
    • Fixed pnpm dedupe to preserve valid catalog resolutions when matching package versions exist in the lockfile.
    • Prevented dedupe from incorrectly resetting catalog resolution data or removing valid resolved versions from the lockfile.

Copilot AI review requested due to automatic review settings July 28, 2026 12:14

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 28, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7de3e42f-94ef-4955-88c1-307118beba7b

📥 Commits

Reviewing files that changed from the base of the PR and between 6592007 and 168bcb9.

📒 Files selected for processing (1)
  • pnpm11/installing/deps-installer/test/catalogs.ts
💤 Files with no reviewable changes (1)
  • pnpm11/installing/deps-installer/test/catalogs.ts

📝 Walkthrough

Walkthrough

pnpm dedupe now preserves existing catalog resolutions while continuing to clear package dependency resolutions for re-resolution. The regression test and patch changeset reflect this behavior.

Changes

Catalog resolution preservation

Layer / File(s) Summary
Preserve catalog lockfile resolutions
pnpm11/installing/deps-installer/src/install/index.ts, pnpm11/installing/deps-installer/test/catalogs.ts, .changeset/quiet-catalogs-dedupe.md
Dedupe cleanup no longer clears catalogs; the test preserves catalog version 100.0.0 and both package versions, and a patch changeset records the fix.

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

Assessment against linked issues

Objective Addressed Explanation
Preserve valid catalog versions during pnpm dedupe [#13465] ✅

Suggested labels: 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 fix-13465

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

Preserve valid catalog resolutions during dedupe

🐞 Bug fix 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Preserve valid catalog lockfile pins while dedupe rebuilds dependency edges.
• Keep changed catalog ranges re-resolvable through existing specifier validation.
• Add regression coverage and patch release notes for catalog dedupe behavior.
Diagram

graph TD
  A["Dedupe run"] --> B["Clear dependency edges"] --> C["Retain catalog snapshot"] --> D{"Specifier matches?"} -->|Yes| E["Reuse locked version"] --> G["Rebuilt lockfile"]
  D -->|No| F["Resolve new version"] --> G
Loading
High-Level Assessment

The PR uses the smallest and safest correction: retain catalog snapshots while continuing to clear only dependency edges. Clearing and later reconstructing catalog snapshots would duplicate the resolver’s existing specifier validation and create more state-transfer risk, so the current approach is preferred.

Files changed (3) +10 / -9

Bug fix (1) +0 / -5
index.tsRetain catalog snapshots during dedupe cleanup +0/-5

Retain catalog snapshots during dedupe cleanup

• Stops 'forgetResolutionsOfAllPrevWantedDeps' from deleting catalog snapshots. Importer and package dependency edges are still cleared and rebuilt, while the resolver can reuse a recorded catalog version after validating its specifier.

pnpm11/installing/deps-installer/src/install/index.ts

Tests (1) +4 / -4
catalogs.tsVerify dedupe preserves valid catalog pins +4/-4

Verify dedupe preserves valid catalog pins

• Changes the catalog dedupe regression test to expect the existing valid '100.0.0' catalog resolution to remain selected even when '100.1.0' is also locked. The test also confirms both package versions remain available after dedupe.

pnpm11/installing/deps-installer/test/catalogs.ts

Documentation (1) +6 / -0
quiet-catalogs-dedupe.mdDocument the catalog dedupe fix +6/-0

Document the catalog dedupe fix

• Adds patch release notes for 'pnpm' and '@pnpm/installing.deps-installer', explaining that dedupe no longer replaces valid catalog resolutions.

.changeset/quiet-catalogs-dedupe.md

@greptile-apps

greptile-apps Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "test(catalogs): remove redundant dedupe ..." | Re-trigger Greptile

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Informational

1. dedupe comment restates assertions ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The comment merely repeats that the following call performs deduplication and that the assertions
expect the valid catalog resolution to remain. It adds no rationale, constraint, or context beyond
the test name and code.
Code

pnpm11/installing/deps-installer/test/catalogs.ts[1169]

+    // Perform a dedupe and expect the valid catalog version to be preserved.
Relevance

⭐ Low

Similar requests to remove duplicative call-site and test comments were rejected repeatedly.

PR-#12876
PR-#13288
PR-#13133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713467 prohibits comments that only restate directly inferable code. The changed
comment describes the dedupe call and expected preservation already expressed by lines 1170–1178.

Rule 713467: Avoid redundant comments that restate the code
pnpm11/installing/deps-installer/test/catalogs.ts[1169-1178]

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

## Issue description
Remove the comment that restates the immediately following dedupe operation and assertions.

## Issue Context
The test name, `dedupe: true` option, and expected lockfile values already communicate the same behavior.

## Fix Focus Areas
- pnpm11/installing/deps-installer/test/catalogs.ts[1169-1169]

ⓘ 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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 28, 2026
@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.

Copilot AI review requested due to automatic review settings July 28, 2026 12:18

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 Jul 28, 2026

Copy link
Copy Markdown
Member Author

Addressed the Qodo maintainability feedback by removing the redundant dedupe test comment in commit 168bcb90a4.


Written by an agent (Codex, GPT-5.6).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 168bcb9

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 11: dedupe updates valid catalog resolutions to latest matching versions

2 participants