Repository navigation
fix(resolving-git-resolver): read git package names during resolution - #13059
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe graph-to-lockfile adapter now handles git-hosted dependency keys and returns structured conversion errors. Git resolution can provide archive manifests, fresh-install paths propagate conversion failures, and tests cover git tarball serialization and malformed dependency paths. ChangesGit dependency lockfile conversion
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant DependenciesGraph
participant GitResolver
participant FetchTarballForResolution
participant LockfileConverter
participant FreshInstall
DependenciesGraph->>GitResolver: resolve git dependency
GitResolver->>FetchTarballForResolution: fetch archive manifest
FetchTarballForResolution-->>GitResolver: return manifest
FreshInstall->>LockfileConverter: build fresh lockfile
LockfileConverter-->>FreshInstall: return lockfile or conversion error
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs (1)
381-384: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick winAvoid string allocation on a hot path.
As per
REVIEW_GUIDE.md, lockfile construction is on a hot path and we should keep extra formatting work targeted. Allocating a new formatted string (format!("{real}@")) for every resolution with areal_nameadds unnecessary overhead. We can achieve the same result with zero allocations by sequentially checking prefixes.⚡ Proposed refactor
- let prefix = format!("{real}@"); if alias == real - && let Some(ver) = dep_path_str.strip_prefix(&prefix) + && let Some(rest) = dep_path_str.strip_prefix(real) + && let Some(ver) = rest.strip_prefix('@') && let Ok(parsed) = ver.parse::<PkgVerPeer>() {🤖 Prompt for 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. In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs` around lines 381 - 384, Update the prefix-matching logic around the PkgVerPeer parsing condition to avoid constructing the formatted `prefix` string. When `alias == real`, sequentially inspect `dep_path_str` for the real package name and following `@` delimiter without allocating, then parse the remaining version as `PkgVerPeer` and preserve the existing behavior.Source: Path instructions
🧹 Nitpick comments (1)
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs (1)
485-487: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse regular comments for private implementation details.
As per coding guidelines, use rustdoc comments (
///) exclusively for public API contracts, and regular comments (//) for implementation rationale.package_keyis a private module-internal helper.♻️ Proposed refactor
-/// Build the lockfile key for a graph node. Registry dep paths already include -/// the package name, while git-hosted dep paths need the name reported by the -/// resolved manifest prepended to their bare tarball URL. +// Build the lockfile key for a graph node. Registry dep paths already include +// the package name, while git-hosted dep paths need the name reported by the +// resolved manifest prepended to their bare tarball URL.🤖 Prompt for 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. In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs` around lines 485 - 487, Change the documentation comment above the private package_key helper from a rustdoc comment to a regular implementation comment, preserving its explanation of registry and git-hosted dependency paths.Source: Coding guidelines
🤖 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 `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs`:
- Line 400: Update the alias comparison in the dependency graph lockfile
conversion logic to avoid allocating with parsed_alias.name.to_string(). Compare
the underlying string directly using parsed_alias.name.as_str() against alias,
while preserving the existing matching behavior.
In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs`:
- Around line 672-677: Update the error assertion in the test to destructure the
expected DependenciesGraphToLockfileError::ImporterDependency variant with a
let-else binding that panics for any other variant, and apply dbg! to the
captured error structure before the field assertions. Preserve the existing
alias and dep_path checks.
---
Outside diff comments:
In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs`:
- Around line 381-384: Update the prefix-matching logic around the PkgVerPeer
parsing condition to avoid constructing the formatted `prefix` string. When
`alias == real`, sequentially inspect `dep_path_str` for the real package name
and following `@` delimiter without allocating, then parse the remaining version
as `PkgVerPeer` and preserve the existing behavior.
---
Nitpick comments:
In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs`:
- Around line 485-487: Change the documentation comment above the private
package_key helper from a rustdoc comment to a regular implementation comment,
preserving its explanation of registry and git-hosted dependency paths.
🪄 Autofix (Beta)
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: 3f8a5bab-9083-4926-9fd5-cfa9b635b499
📒 Files selected for processing (4)
.changeset/git-importer-lockfile.mdpnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
Confidence Score: 4/5Safe to merge for the panic fix and host-archive deps; the unaliased non-archive Git dep case (ssh, self-hosted, git+file://) still writes a version: name@git+url alias form instead of the plain version: git+url ref pnpm v11 uses, but this is narrower than the pre-PR state where the same shape caused a hard crash. The PR correctly fixes the primary panic and produces byte-identical lockfiles for the tested shapes (host archive, host archive + #path:, aliased Git dep). One untested shape — an unaliased dep resolved to a LockfileResolution::Git (ssh, self-hosted, git+file://) — would write a lockfile with version: my-package@git+file://... in the importer entry and snapshot child refs, where pnpm v11 writes the plain version: git+file://... form. The real_name function's reads_name_from_manifest match does not include LockfileResolution::Git(_), and the validation table explicitly notes the Git fixture used an aliased dep, confirming this path was not exercised. pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs — the real_name function's reads_name_from_manifest match needs LockfileResolution::Git(_) => true to cover unaliased non-archive git deps, and tests should be added for the unaliased Git resolution case in dependencies_graph_to_lockfile/tests.rs.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13059 +/- ##
==========================================
- Coverage 85.59% 85.45% -0.15%
==========================================
Files 499 501 +2
Lines 79945 80622 +677
==========================================
+ Hits 68431 68893 +462
- Misses 11514 11729 +215 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.9088446442200007,
"stddev": 0.1239690265400809,
"median": 2.9337952086200003,
"user": 3.10335302,
"system": 2.2413206,
"min": 2.71521416262,
"max": 3.10145161262,
"times": [
2.90178819262,
2.75179487362,
2.97741628362,
3.0154965806200003,
2.71521416262,
3.10145161262,
2.96580222462,
2.98727924562,
2.7976679566200002,
2.87453530962
]
},
{
"command": "pacquet@main",
"mean": 3.00480210162,
"stddev": 0.20510690151799366,
"median": 2.9689012521200002,
"user": 3.3094855200000004,
"system": 2.4949364,
"min": 2.68536223762,
"max": 3.27056078962,
"times": [
2.95006573562,
2.80749857762,
2.81531657362,
3.08509763462,
3.23184234862,
3.26447461462,
2.9765936006200002,
3.27056078962,
2.68536223762,
2.96120890362
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6756974329200003,
"stddev": 0.1516305192495456,
"median": 1.6630417781200002,
"user": 1.9642330200000004,
"system": 1.8691658999999998,
"min": 1.49284516062,
"max": 1.9059152696200001,
"times": [
1.67121639262,
1.59137626862,
1.9059152696200001,
1.9045165936200001,
1.68382016362,
1.5011707246200001,
1.55306042462,
1.79818616762,
1.65486716362,
1.49284516062
]
},
{
"command": "pnpr@main",
"mean": 1.7270529501199998,
"stddev": 0.14771613090945718,
"median": 1.7627437431200002,
"user": 1.96977212,
"system": 1.9496227000000002,
"min": 1.48413989062,
"max": 1.8921423426200001,
"times": [
1.84438641062,
1.6109736456200001,
1.8878782276200001,
1.8039029906200001,
1.7215844956200002,
1.68084279562,
1.52578807462,
1.81889062762,
1.8921423426200001,
1.48413989062
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.37853279408,
"stddev": 0.04942760023451485,
"median": 0.37938178248,
"user": 0.35991714,
"system": 0.9272600399999998,
"min": 0.29954616148,
"max": 0.45743975648,
"times": [
0.40944997248000004,
0.34869819548000003,
0.40206383148,
0.41650274848,
0.42061563348000003,
0.45743975648,
0.33498154748000003,
0.33933036048000004,
0.29954616148,
0.35669973348
]
},
{
"command": "pacquet@main",
"mean": 0.37805432908,
"stddev": 0.08755745583161374,
"median": 0.34049094148000003,
"user": 0.35982994,
"system": 0.9719891399999998,
"min": 0.29194431048,
"max": 0.57134836948,
"times": [
0.32691457748,
0.29194431048,
0.32477534448,
0.34014718448000003,
0.47872605448,
0.42259512348,
0.57134836948,
0.34083469848000003,
0.31743419248,
0.36582343548
]
},
{
"command": "pnpr@HEAD",
"mean": 0.34125378368000003,
"stddev": 0.02750944000210841,
"median": 0.33895246148,
"user": 0.33278354,
"system": 0.7998424399999999,
"min": 0.30149968548,
"max": 0.39358945648000004,
"times": [
0.34465109048000003,
0.32449340948,
0.30149968548,
0.33427315948,
0.34363176348,
0.37777092648,
0.39358945648000004,
0.31447123448000003,
0.34557497748,
0.33258213348000004
]
},
{
"command": "pnpr@main",
"mean": 0.33603080528000007,
"stddev": 0.022791852315346202,
"median": 0.33218152198000006,
"user": 0.32407434,
"system": 0.7897380399999999,
"min": 0.30388401748,
"max": 0.36849608248000004,
"times": [
0.34112029448000003,
0.31496248748,
0.35077178048,
0.31953711148,
0.32324274948000004,
0.36261425548000004,
0.36849608248000004,
0.35722949848,
0.31844977548000003,
0.30388401748
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0393231283200004,
"stddev": 0.046731883076622904,
"median": 3.04661584692,
"user": 2.8765128399999993,
"system": 2.00312154,
"min": 2.96489198892,
"max": 3.10944689192,
"times": [
3.0813171379199997,
3.0472434959199997,
3.10944689192,
3.00990460292,
3.03361936592,
3.04598819792,
3.07814471292,
2.97037809792,
3.05229679092,
2.96489198892
]
},
{
"command": "pacquet@main",
"mean": 3.0785275149199998,
"stddev": 0.0766866574355403,
"median": 3.0672360989199996,
"user": 2.8592164399999995,
"system": 2.05348784,
"min": 2.97567595692,
"max": 3.20602377492,
"times": [
3.05880913292,
3.00114767392,
3.01459154192,
2.97567595692,
3.0756630649199996,
3.12380567592,
3.17248402592,
3.12723748692,
3.20602377492,
3.02983681492
]
},
{
"command": "pnpr@HEAD",
"mean": 1.79343107342,
"stddev": 0.1110055294420303,
"median": 1.8055742859200001,
"user": 1.72537954,
"system": 1.69230204,
"min": 1.6302104999200002,
"max": 1.9280846869200001,
"times": [
1.82397091792,
1.7871776539200002,
1.8617523039200001,
1.9280846869200001,
1.63071304492,
1.7492390499200001,
1.8916740899200002,
1.7122783509200001,
1.6302104999200002,
1.91921013592
]
},
{
"command": "pnpr@main",
"mean": 1.6738053273200002,
"stddev": 0.16765612686884257,
"median": 1.62120692792,
"user": 1.70518114,
"system": 1.64702324,
"min": 1.48732717392,
"max": 1.9320757369200001,
"times": [
1.81938784792,
1.48732717392,
1.4951458829200002,
1.6364330339200002,
1.60598082192,
1.9320757369200001,
1.5374211589200002,
1.92718677692,
1.58408641492,
1.7130084249200002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.0169890406,
"stddev": 0.11606754901439603,
"median": 1.0722959114,
"user": 1.27308704,
"system": 1.01683734,
"min": 0.8071683879000001,
"max": 1.1446416909000001,
"times": [
0.9175741359,
0.8071683879000001,
1.0808164469000001,
1.0234030339,
1.0835438059,
1.0873204149,
1.0637753759,
1.1087803719,
1.1446416909000001,
0.8528667419000001
]
},
{
"command": "pacquet@main",
"mean": 0.9321516084999999,
"stddev": 0.14188291412549642,
"median": 0.8678295844000001,
"user": 1.15110394,
"system": 0.9867198399999999,
"min": 0.7470823129,
"max": 1.1563999309000002,
"times": [
0.8531669309000001,
0.7470823129,
0.8677870729000001,
0.8678720959,
1.1563999309000002,
0.7813280179000001,
1.0788627949,
1.0809227109,
1.0319046489,
0.8561895689000001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3575994402,
"stddev": 0.01621187201977052,
"median": 0.35178163040000004,
"user": 0.28973534,
"system": 0.7489404399999999,
"min": 0.33573728290000004,
"max": 0.3890069729,
"times": [
0.35447363890000005,
0.33573728290000004,
0.3477252659,
0.35137816090000007,
0.38060633390000004,
0.35086438290000005,
0.3656795749,
0.3890069729,
0.34833768890000005,
0.3521850999
]
},
{
"command": "pnpr@main",
"mean": 0.3600825390000001,
"stddev": 0.03414951511711855,
"median": 0.35543039790000003,
"user": 0.27312424,
"system": 0.81118904,
"min": 0.32001880090000007,
"max": 0.4244933349000001,
"times": [
0.3260978809,
0.32976031390000005,
0.33854679590000003,
0.34815811290000004,
0.3709864809,
0.4244933349000001,
0.3984553129,
0.38160567390000005,
0.3627026829,
0.32001880090000007
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.2464502085599998,
"stddev": 0.12547397778906502,
"median": 2.21527380776,
"user": 1.5714226999999998,
"system": 1.2041262599999996,
"min": 2.10161292476,
"max": 2.56745788876,
"times": [
2.56745788876,
2.2152558277599996,
2.3055987237599997,
2.21529178776,
2.21208466376,
2.15298691376,
2.10161292476,
2.2093467467599996,
2.2211976867599996,
2.26366892176
]
},
{
"command": "pacquet@main",
"mean": 2.1582334115599995,
"stddev": 0.07486577644490208,
"median": 2.1353155172599996,
"user": 1.5359135000000002,
"system": 1.11799996,
"min": 2.06204252576,
"max": 2.29675975376,
"times": [
2.13999612276,
2.29675975376,
2.1216073287599997,
2.08793035776,
2.1306349117599996,
2.2532242237599998,
2.21100920676,
2.06204252576,
2.1721062867599996,
2.10702339776
]
},
{
"command": "pnpr@HEAD",
"mean": 0.34395704866,
"stddev": 0.024103766689863786,
"median": 0.34450193776000004,
"user": 0.2805656,
"system": 0.6941631600000001,
"min": 0.30953251476000004,
"max": 0.38371495176000003,
"times": [
0.31513412176,
0.33896042776,
0.32571716276,
0.35004344776,
0.33375168876,
0.35396943076000004,
0.38371495176000003,
0.37436512076,
0.35438161976000004,
0.30953251476000004
]
},
{
"command": "pnpr@main",
"mean": 0.35314684516000006,
"stddev": 0.029359225966354454,
"median": 0.35703673476000003,
"user": 0.2963227,
"system": 0.75612796,
"min": 0.28235088576,
"max": 0.38879468276,
"times": [
0.36031841676000004,
0.34974720576,
0.35845539976,
0.35492538976000004,
0.35561806976000004,
0.38879468276,
0.38235017476000005,
0.28235088576,
0.33373319976000004,
0.36517502676
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.48569925502,
"stddev": 0.03425611450805146,
"median": 0.47512376352,
"user": 0.47985032,
"system": 0.1070586,
"min": 0.44188511002,
"max": 0.5599661080200001,
"times": [
0.47697559802,
0.5599661080200001,
0.45818997502000003,
0.44188511002,
0.46453465002,
0.47327192902000004,
0.51436429102,
0.50468147602,
0.46615718702000003,
0.49696622602
]
},
{
"command": "pacquet@main",
"mean": 0.49071248662,
"stddev": 0.054155140774257204,
"median": 0.47420725902000005,
"user": 0.47715142000000005,
"system": 0.11743679999999998,
"min": 0.42954979102,
"max": 0.6039409560200001,
"times": [
0.6039409560200001,
0.47020753702,
0.48836356902,
0.5671119120200001,
0.49507800702000004,
0.42954979102,
0.46309795602000003,
0.44597046202,
0.46559769502000004,
0.47820698102000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09679206788666671,
"stddev": 0.004013064656364199,
"median": 0.09584246552,
"user": 0.02381045333333333,
"system": 0.01497133333333333,
"min": 0.08915566402000001,
"max": 0.10536828002000001,
"times": [
0.09159760802,
0.09581852302,
0.09470826502,
0.09494256802,
0.09836590602,
0.09914360302000001,
0.09445996802,
0.09084767802,
0.09545022902,
0.09824788802000001,
0.08915566402000001,
0.09435699502,
0.09455099702,
0.10004202802,
0.10536828002000001,
0.10213275002000001,
0.10402826602000001,
0.09586640802,
0.10198638502,
0.10091409302000001,
0.10029651202,
0.09473684202,
0.09430487702000001,
0.09329485102,
0.09170837402000001,
0.09818704702,
0.09226931902,
0.09915689002,
0.09796214902,
0.09986107302000001
]
},
{
"command": "pnpr@main",
"mean": 0.09432331315333334,
"stddev": 0.007506124320430236,
"median": 0.09339013302000002,
"user": 0.02188195333333333,
"system": 0.0151479,
"min": 0.08521125002,
"max": 0.11785025202,
"times": [
0.09171022702,
0.09693867802,
0.08688921702,
0.09412465902,
0.09394517002000001,
0.09437676702,
0.08672177102,
0.08521125002,
0.08604537602000001,
0.09066606602,
0.08946409902,
0.09001321902000001,
0.08918817102,
0.08824877702,
0.09309144402000001,
0.09999991302000001,
0.09400821402000001,
0.08701993102000001,
0.08954899302000001,
0.10761888602000001,
0.09677263702000001,
0.10155421502,
0.09662130802,
0.09732234802,
0.10791857502,
0.09368882202,
0.08730275902000001,
0.09228749802000001,
0.10355015202000001,
0.11785025202
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.674916118819999,
"stddev": 0.19750466225351163,
"median": 4.59098129002,
"user": 2.7097316,
"system": 1.9768679200000001,
"min": 4.55558750302,
"max": 5.13969579902,
"times": [
5.13969579902,
4.62622211402,
4.57352733702,
4.58399311502,
4.93115438902,
4.61095526002,
4.55558750302,
4.597969465019999,
4.55890483202,
4.57115137402
]
},
{
"command": "pacquet@main",
"mean": 4.73312664962,
"stddev": 0.22395451659169432,
"median": 4.69153950702,
"user": 2.9997318,
"system": 2.31474082,
"min": 4.50534138402,
"max": 5.11457790102,
"times": [
4.50534138402,
4.52089980702,
4.52263123702,
5.04460231602,
4.72671076202,
4.65636825202,
4.5747402490199995,
4.74105693902,
5.11457790102,
4.92433764902
]
},
{
"command": "pnpr@HEAD",
"mean": 3.8135459966200003,
"stddev": 0.07358842107867747,
"median": 3.78286161702,
"user": 2.461633,
"system": 2.2365473199999997,
"min": 3.70446559002,
"max": 3.9285786580199997,
"times": [
3.7895382940199998,
3.89529738402,
3.9285786580199997,
3.77475467002,
3.87712478202,
3.77618494002,
3.8717349630199998,
3.70446559002,
3.7542384800199997,
3.76354220502
]
},
{
"command": "pnpr@main",
"mean": 3.95721321622,
"stddev": 0.17098179724493445,
"median": 3.92496733752,
"user": 2.5422866999999996,
"system": 2.2103196199999995,
"min": 3.76609799302,
"max": 4.22142683902,
"times": [
3.98802586502,
3.89603671802,
3.8034682000199997,
3.8141021890199998,
4.17182022202,
4.15324835902,
3.76609799302,
4.22142683902,
3.9538979570199997,
3.80400782002
]
}
]
} |
|
| Branch | pr/13059 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,793.43 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 343.96 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 357.60 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 96.79 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,675.70 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,813.55 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 341.25 ms |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
2 similar comments
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
A git dep's specifier names a repo, not a package, so its name is only readable from the package.json in the host's archive. The git resolver left `manifest` unset, so `build_pkg_id_with_patch_hash` had no name to prefix and emitted a bare archive URL as the dep path, which no lockfile key parses. Read the manifest during resolution, as the tarball resolver already does for remote tarballs and as upstream's package requester does when a resolver returns no manifest. Dep paths then carry the `<name>@` prefix and parse as ordinary lockfile keys, so the graph-to-lockfile adapter needs no git-specific key reconstruction. The fetch stops at the raw archive: the prepare/prepublish pass and its packlist filtering stay in the install pass, so no package script runs during resolution. `real_name` now covers git-hosted tarballs, matching upstream's `depPathToRef`: an unaliased git dep records `version: <url>`, while a renamed one keeps the `<name>@<ref>` alias form that composes back to its snapshot key. Reading the name off a `Git` resolution (a private/ssh repo with no archive endpoint) needs a clone rather than a download, and stays out of scope. Closes pnpm#13040.
`perfectionist::macro_trailing_comma` requires a trailing comma on a multi-line macro invocation; the pre-push dylint run rejects it without.
6fef22d to
3bbdd07
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs (1)
481-502: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPropagate malformed package keys instead of silently dropping nodes.
Despite making this builder fallible, Line 491 still skips an invalid
PackageKey. A malformed transitive node can therefore disappear frompackagesandsnapshotswhile parent snapshots retain references to it. Return a contextual conversion error here instead.As per path instructions, malformed dependency identities must produce recoverable contextual errors rather than incomplete lockfiles.
🤖 Prompt for 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. In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs` around lines 481 - 502, Update build_packages_and_snapshots so parsing node.dep_path into PackageKey propagates a recoverable, contextual conversion error instead of continuing when parsing fails. Preserve normal package and snapshot insertion for valid keys, and include the malformed dependency identity in the returned DependenciesGraphToLockfileError.Source: Path instructions
🤖 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 `@pnpm/crates/resolving-git-resolver/src/git_resolver.rs`:
- Around line 130-141: Update the FetchTarballForResolution construction in the
git resolution flow to propagate tarball.path into manifest extraction, so
repository subdirectory dependencies read that subdirectory’s package.json
rather than the archive root. Preserve git-hosted identity handling and lockfile
records consistent with pnpm, and add a regression test covering a git
dependency targeting a repository subdirectory.
---
Outside diff comments:
In `@pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs`:
- Around line 481-502: Update build_packages_and_snapshots so parsing
node.dep_path into PackageKey propagates a recoverable, contextual conversion
error instead of continuing when parsing fails. Preserve normal package and
snapshot insertion for valid keys, and include the malformed dependency identity
in the returned DependenciesGraphToLockfileError.
🪄 Autofix (Beta)
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: 3b308fc3-61f6-4390-98d0-429f68909785
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock,!Cargo.lock
📒 Files selected for processing (8)
.changeset/git-importer-lockfile.mdpnpm/crates/napi/src/resolve.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/resolving-git-resolver/Cargo.tomlpnpm/crates/resolving-git-resolver/src/git_resolver.rspnpm/crates/resolving-git-resolver/src/lib.rs
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
PR Code Suggestions ✨Latest suggestions up to a1dbcfe Warning
Previous suggestionsSuggestions up to commit af3bd4d
Suggestions up to commit 023b2be
Suggestions up to commit 3bbdd07
|
||||||||||||||||||||||||||||||||||||||||
A git dep can point at one directory of a repo (`#path:/packages/foo`), but the host serves an archive spanning the whole repo. Extraction only stashes the root `package.json` on the files index, so resolving such a dep read the repo's manifest and derived the wrong package name — and therefore the wrong lockfile key. Give `FetchTarballForResolution` an optional subdirectory and read `<subdir>/package.json` back from the CAS when it is set. A subdirectory without a `package.json` degrades to `None`, matching the archive root's best-effort contract rather than falling back to the root's manifest. The other two call sites pass `None`: a plain remote tarball is the package, and the prefetching resolver reads only integrity and filters git-hosted archives out already. Reported by CodeRabbit on pnpm#13059.
|
Code review by qodo was updated up to the latest commit 023b2be |
Summary
A non-frozen
pnpm installof a workspace containing git-hosted dependencies aborted with a panic while building the lockfile. Closes #13040.The root cause is upstream of the lockfile: a git dep's specifier names a repo, not a package, so its name is only readable from the
package.jsonin the host's archive. The git resolver leftmanifestunset, sobuild_pkg_id_with_patch_hashhad no name to prefix and emitted a bare archive URL as the dep path — a shape no lockfile key parses (MissingSuffix, since the URL contains no@).This PR fixes it where the name goes missing:
GitResolverreads the archive'spackage.jsonduring resolution, given aGitFetchContext. This mirrorsTarballResolver, which already downloads a remote tarball at resolve time to fillmanifest+integrity, and matches upstream, whose package requester awaits the fetch when a resolver returns no manifest (packageRequester.ts,if (!manifest) { const fetchedResult = await fetchResult.fetching() ... }) sogetManifestFromResponsecan handresolveDependenciesa realpkg.name.<name>@prefix and parse as ordinary lockfile keys, so the graph→lockfile adapter needs no git-specific key reconstruction.real_namenow covers git-hosted tarballs, matching upstream'sdepPathToRef: an unaliased git dep recordsversion: <url>, while a renamed one keeps the<name>@<ref>alias form that composes back to its snapshot key.integrityis recorded from the bytes the same fetch already hashes. Without it the install pass refuses the dep outright (tarball_url_and_integrityrequires an integrity on every tarball resolution), so a git dep would resolve into a lockfile it could never install from..expect()that panicked is still replaced by a propagated error, as the issue asked, so an unexpected dep-path shape degrades gracefully instead of aborting the process.The fetch stops at the raw archive: the git-hosted
prepare/prepublishpass and its packlist filtering stay in the install pass, so no package script runs during resolution. The install pass re-fetches the archive to run them — unlike a registry tarball, a git-hosted one can't hand its extraction over throughMemCache(onlyRegistryresolutions read it) — so a git dep costs one extra archive download per install. Closing that gap is an optimization, not a correctness fix, and would mean revisiting a deliberate exclusion ininstall_package_by_snapshot.Only
github.com,gitlab.comandbitbucket.orgresolve to a host archive. Every other repo — self-hosted,file:, and any ssh URL, even to GitHub — resolves toGit, which has no archive endpoint, so its name is read from a throwaway checkout instead. That path was the same bug one layer down: no manifest meant no<name>@prefix, the dep path failedPackageKeyparsing, andbuild_packages_and_snapshotssilently dropped the package while the importer kept pointing at it — a--frozen-lockfileinstall off that lockfile exited 0 and left a dangling symlink. The clone/checkout is extracted out ofGitFetcherso both passes share one implementation, including itsis_valid_commit_hashguard.Further fixes that fell out of driving this end to end:
safe_join_pathtreated a sub-path as absolute. A resolution'spathkeeps the leading slash of#path:/packages/foo, andPath::joindiscards the root when its argument is absolute — unlike thepath.joinupstream uses. Every sub-directory git dep failed to install with "is not a valid sub-directory of the git checkout".No TypeScript change: upstream already behaves this way, and already writes this lockfile shape. This brings pacquet in line.
Security
Resolution now shells out to
git, which moved two hazards from the install pass into the resolve pass. Both are reachable from a manifest or lockfile — the threat modelInvalidCommit's doc comment already names ("allowing a malicious lockfile to execute arbitrary commands on SSH or local-file transports"). Worth a reviewer's attention over the rest of the diff.checkout_commitpassedrepotogit clone/git remote addas a positional. Git reads a--leading value as an option instead, and--upload-pack=<cmd>runs<cmd>on a local or SSH transport — confirmed by experiment (git clone --upload-pack="touch X" src destcreatesX).commitwas already guarded byis_valid_commit_hashfor exactly this; its siblingrepo, off the same untrustedGitResolution, never was. Now rejected via a structuredInvalidRepoerror and fenced with--before the positional, so neither defence stands alone. This hole pre-dated the PR on the install path; the fix covers both.#path:/../..climbed out of the checkout — andsafe_read_package_json_from_dirreads whatever it is handed, so an arbitrarypackage.jsonon the host became that dep's name and version in the lockfile. It now reuses the install pass'ssafe_join_path(canonicalize +starts_withroot), rather than keeping a second, weaker copy of the same logic.Squash Commit Body
Checklist
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.
Validation
Driven end to end against the real hosts and a real repo, not just tests. All three git shapes now write the lockfile pnpm 11.13.1 writes for the same manifest, byte for byte (
diffempty):github:kevva/is-negative#163360a#path:RexSkz/test-git-subfolder-fetch#path:/packages/simple-express-serverGit)git+file://, aliasedpnpm installof the host-archive dep linksnode_modulesand the package runs (is-negative(-1) === true); theGitdep resolves andrequire()returns its export; the#path:dep installs@my-namespace/simple-express-server.monorepo-example/the-monorepowhile the subpackage is@my-namespace/simple-express-server/@scope/foo, and theGitfixture's alias (aliased-dep) differs from its real name (my-real-pkg-name) — so key, importer ref, version and transitive deps all prove the right manifest is being read.packages:orsnapshots:entry.Automated gate:
cargo nextest runacrosspacquet-git-fetcher,pacquet-tarball,pacquet-resolving-git-resolver,pacquet-resolving-tarball-resolver,pacquet-package-manager— 928 passed.cargo fmt --all -- --check,taplo format --check,cargo clippy --workspace --all-targets -- -D warnings,RUSTDOCFLAGS=-D warnings cargo doc,cargo dylint --all --workspace,typos,cspell— all clean.--upload-pack=touch <marker>repo is refused and that the marker never appears; the traversal test puts a realpackage.jsonoutside the checkout and asserts/../..,../..and/../are all rejected.Known divergence from upstream
Upstream serves resolve-time and install-time from one memoized
fetchPackageToStore. pacquet keeps its resolvers and its install pass on separate fetch paths, so a git dep is fetched twice: once here for the name, once by the install pass to runprepareover it. Correct, but a real cost, and unifying the two is a larger change than this fix. Noted rather than hidden.Written by an agent (Claude Code, claude-opus-4-8).