Repository navigation
fix(catalogs): honor a wanted version the catalog entry already resolves past - #13841
Conversation
…ves past Under a non-manual catalogMode, a wanted version the catalog entry covers resolves through the catalog. When the entry was a range whose recorded resolution named a different version, that resolution was reused and the wanted version was dropped without a word: `pnpm add <pkg>@<version>` and `pnpm update <pkg>@<version>` wrote nothing to the lockfile and raised no error, so the command looked like it had worked. The recorded resolution is now cleared for the entry, along with the resolutions the installed projects took from it, and the wanted version is preferred above the pin the lockfile seeds, so the entry resolves to the version that was asked for. The range the workspace declared is untouched by this; saving still re-renders it onto the resolved version the way it does for a manifest dependency. Projects outside the install keep their resolutions, as they already do for any catalog change, until they are installed themselves. pacquet honors the wanted version on `update` already, but has the same silent no-op on `add`. That port is not in this commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughVersion-pinned ChangesCatalog version resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
| // Drop the recorded resolution, along with the ones the installed projects took from | ||
| // it, so the entry is resolved again instead of reused at the version it named before. | ||
| // Projects outside this install keep theirs until they are installed themselves. | ||
| delete ctx.wantedLockfile.catalogs?.[catalogName]?.[alias] |
PR Summary by QodoFix catalog strict mode to honor requested versions covered by catalog ranges
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Confidence Score: 5/5The PR appears safe to merge because no blocking failure remains. No blocking failure remains. Reviews (2): Last reviewed commit: "fix(catalogs): build the preferred-versi..." | Re-trigger Greptile |
Code Review by Qodo
1. Pacquet catalog move not ported
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@pnpm11/installing/deps-installer/src/install/index.ts`:
- Around line 1187-1191: The add installation flow around resolveCatalogEntryTo
must invalidate the affected dependency’s catalog snapshot when a concrete
requested version is covered by an existing catalog range, while retaining the
catalog entry itself. Ensure UpdateSeedPolicy::KeepAll cannot reuse the stale
snapshot, and add a regression test covering this concrete-version request
scenario.
In `@pnpm11/installing/deps-installer/test/catalogs.ts`:
- Around line 1679-1682: Extend the assertions in the catalog lockfile test
after the project1 mutation to verify that project2 still resolves `@pnpm.e2e/foo`
at 1.0.0 and that the 1.0.0 snapshot remains present. Keep the existing project1
and catalog assertions unchanged.
🪄 Autofix
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: 428d56e4-c7e0-45b0-94e8-b0ec0cf3980a
📒 Files selected for processing (4)
.changeset/catalog-locked-version-noop.mdpnpm11/installing/deps-installer/src/install/extendInstallOptions.tspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-installer/test/catalogs.ts
A package named `__proto__` reached an object literal's computed key, so the merge could touch Object.prototype instead of adding an own property. Build both merge targets with Object.create(null), matching the seed merge in installInContext. Also pin that a project outside the install keeps the version the catalog entry resolved to before, and drop the comments that restated the assertions and the deletions they sit next to. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit c7735c5 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Follow-up to #13716, which stopped
catalogMode: strictfrom rejecting a version arange-based catalog entry covers. That left a hole: when the entry's recorded resolution
names a different version than the one asked for, the request was dropped silently.
pnpm add @pnpm.e2e/[email protected](orpnpm update @pnpm.e2e/[email protected]) wrote nothing — not thelockfile, not
pnpm-workspace.yaml— and raised no error. The same swallows an explicitdowngrade: with the entry resolved to 1.3.0, asking for
@1.1.0also did nothing.A cataloged dependency takes its version from the catalog, so the wanted version now moves the
entry's resolution: the recorded resolution is cleared, along with the resolutions the
installed projects took from it, and the wanted version is preferred above the pin the lockfile
seeds. The range the workspace declared is not touched by this — saving still re-renders it
onto the resolved version, exactly as it does for a manifest dependency.
Projects outside the install keep their resolutions until they are installed themselves, which
is what already happens for any other catalog change.
Related to #13715.
Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Still to port: pacquet honors the wanted version on
updatealready — measured with arange entry resolved to 100.0.0,
pacquet update <pkg>@100.1.0moves the lockfile to 100.1.0 —but
pacquet add <pkg>@<version>has the same silent no-op this PR fixes for pnpm. I'm workingon that port next; it belongs in this PR before it lands.
One pre-existing difference the two stacks keep either way, which this PR does not touch:
pnpm re-renders a catalog entry's declared range when a save moves it (
^1.0.0→^1.1.0),pacquet leaves the range alone and moves only the resolved version.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
pnpm addandpnpm updatecommands now update catalog resolutions to the requested version when applicable.catalog:references.Tests