Commit 9758a00
committed
fix(plugins): make managed downgrade guard ENOENT-safe and stop leaking stale resolution
Addresses ClawSweeper [P1]/[P2] on #85305.
[P1] readManagedNpmRootInstalledDependency read package-lock.json with the
strict readJson, so a fresh managed npm root (no lockfile yet) threw instead
of returning null. The downgrade guard reads installed metadata before npm
install creates the lockfile, so a fresh plugin install crashed. Switch to
the ENOENT-safe readJsonIfExists (already used elsewhere in this file for the
same lockfile), so a missing lockfile yields null (no installed dependency).
[P2] When the guard preserved a newer installed dependency, the returned
expectedNpmResolution spread the older incoming resolution and only overwrote
version/integrity, leaving stale resolvedSpec/shasum/resolvedAt from the
rejected downgrade target. Construct a clean resolution carrying only the kept
version's name/version/integrity so persisted install records do not mix
metadata.
Tests: fresh-root reader test (returns null without a lockfile) and a
preserved-resolution assertion (no stale shasum/resolvedSpec).1 parent 51b946a commit 9758a00
4 files changed
Lines changed: 34 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
373 | 373 | | |
374 | 374 | | |
375 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
376 | 391 | | |
377 | 392 | | |
378 | 393 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1002 | 1002 | | |
1003 | 1003 | | |
1004 | 1004 | | |
1005 | | - | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
1006 | 1009 | | |
1007 | 1010 | | |
1008 | 1011 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
786 | 786 | | |
787 | 787 | | |
788 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
789 | 796 | | |
790 | 797 | | |
791 | 798 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | | - | |
920 | | - | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
921 | 926 | | |
922 | | - | |
923 | | - | |
924 | | - | |
| 927 | + | |
925 | 928 | | |
926 | 929 | | |
927 | 930 | | |
| |||
0 commit comments