Skip to content

fix(resolving-git-resolver): read git package names during resolution - #13059

Merged
zkochan merged 10 commits into
pnpm:mainfrom
DebadityaHait:fix/git-dependency-lockfile-panic
Jul 17, 2026
Merged

zkochan merged 10 commits into
pnpm:mainfrom
DebadityaHait:fix/git-dependency-lockfile-panic

Conversation

@DebadityaHait

@DebadityaHait DebadityaHait commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A non-frozen pnpm install of 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.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 — a shape no lockfile key parses (MissingSuffix, since the URL contains no @).

This PR fixes it where the name goes missing:

  • GitResolver reads the archive's package.json during resolution, given a GitFetchContext. This mirrors TarballResolver, which already downloads a remote tarball at resolve time to fill manifest + 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() ... }) so getManifestFromResponse can hand resolveDependencies a real pkg.name.
  • Dep paths then carry the <name>@ prefix and parse as ordinary lockfile keys, so the graph→lockfile adapter needs no git-specific key reconstruction.
  • 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.
  • The archive's integrity is recorded from the bytes the same fetch already hashes. Without it the install pass refuses the dep outright (tarball_url_and_integrity requires an integrity on every tarball resolution), so a git dep would resolve into a lockfile it could never install from.
  • The .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/prepublish pass 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 through MemCache (only Registry resolutions 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 in install_package_by_snapshot.

Only github.com, gitlab.com and bitbucket.org resolve to a host archive. Every other repo — self-hosted, file:, and any ssh URL, even to GitHub — resolves to Git, 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 failed PackageKey parsing, and build_packages_and_snapshots silently dropped the package while the importer kept pointing at it — a --frozen-lockfile install off that lockfile exited 0 and left a dangling symlink. The clone/checkout is extracted out of GitFetcher so both passes share one implementation, including its is_valid_commit_hash guard.

Further fixes that fell out of driving this end to end:

  • safe_join_path treated a sub-path as absolute. A resolution's path keeps the leading slash of #path:/packages/foo, and Path::join discards the root when its argument is absolute — unlike the path.join upstream uses. Every sub-directory git dep failed to install with "is not a valid sub-directory of the git checkout".
  • A sub-directory package got no store-index row. Its key named the subpackage while the payload described the whole repo.
  • Two git-argument hardenings — see Security below.

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 model InvalidCommit'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.

  • Repo option injection. checkout_commit passed repo to git clone / git remote add as 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 dest creates X). commit was already guarded by is_valid_commit_hash for exactly this; its sibling repo, off the same untrusted GitResolution, never was. Now rejected via a structured InvalidRepo error 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.
  • Sub-path traversal at resolve time. The resolve-time manifest read built its package directory by stripping a leading separator and joining, with no containment check, so #path:/../.. climbed out of the checkout — and safe_read_package_json_from_dir reads whatever it is handed, so an arbitrary package.json on the host became that dep's name and version in the lockfile. It now reuses the install pass's safe_join_path (canonicalize + starts_with root), rather than keeping a second, weaker copy of the same logic.

Squash Commit Body

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 — the graph-to-lockfile conversion then panicked on it.

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. The install pass re-fetches the archive to run them,
so a git dep costs one extra archive download per install.

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

Record the archive's integrity from the bytes that fetch already
hashes. The install pass refuses a tarball resolution without one, so a
git dep otherwise resolved into a lockfile it could never install from.
With it, a pacquet lockfile for a git dep is byte-identical to pnpm
11's for the same manifest.

Replace the `.expect()` on the importer dep path with a propagated,
contextual error so an unexpected shape degrades gracefully instead of
aborting the process.

A repo with no archive endpoint (self-hosted, `file:`, or any ssh URL)
has its name read from a throwaway checkout instead; the clone is
extracted out of `GitFetcher` so both passes share one implementation.
Without it such a dep resolved with no name, failed `PackageKey`
parsing, and was silently dropped from `packages:` / `snapshots:` while
the importer still pointed at it — a frozen install off that lockfile
exited 0 and left a dangling symlink.

Also strip the leading slash from a resolution's `path` before joining
it onto the checkout: `Path::join` discards the root on an absolute
argument, unlike upstream's `path.join`, so every sub-directory git dep
failed to install.

Guard the two git arguments this newly reaches from resolution. `repo`
was passed to `git clone` / `git remote add` as a positional, and git
reads a `-`-leading value as an option, so `--upload-pack=<cmd>` ran
`<cmd>` on a local or SSH transport; `commit` was already guarded for
this, `repo` was not. Reject the shape and pass `--` before the
positional. The resolve-time manifest read joined its sub-path with no
containment check, letting `#path:/../..` read an arbitrary
`package.json` off the host and stamp its name onto the dep; it reuses
the install pass's `safe_join_path` instead of a second weaker copy.

Closes pnpm/pnpm#13040.

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.

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 (diff empty):

shape fixture before
host archive github:kevva/is-negative#163360a panic (#13040)
host archive, #path: RexSkz/test-git-subfolder-fetch#path:/packages/simple-express-server panic; then install failed on the sub-path
no archive (Git) local repo over git+file://, aliased panic; then dangling symlink
  • pnpm install of the host-archive dep links node_modules and the package runs (is-negative(-1) === true); the Git dep resolves and require() returns its export; the #path: dep installs @my-namespace/simple-express-server.
  • The sub-directory fixtures are discriminating by construction: the repo root is monorepo-example / the-monorepo while the subpackage is @my-namespace/simple-express-server / @scope/foo, and the Git fixture'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.
  • Disabling only the resolve-time read and rerunning shows why it is load-bearing: the install exits 0 and writes a lockfile whose importer references a package with no packages: or snapshots: entry.

Automated gate:

  • cargo nextest run across pacquet-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.
  • Both hardenings are covered by tests that drive the real payload: the injection test asserts a --upload-pack=touch <marker> repo is refused and that the marker never appears; the traversal test puts a real package.json outside the checkout and asserts /../.., ../.. and /../ are all rejected.
  • Every new test was verified to fail when the code it covers is reverted, rather than passing vacuously.

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 run prepare over 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).

@DebadityaHait
DebadityaHait requested a review from zkochan as a code owner July 15, 2026 22:36
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

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

Changes

Git dependency lockfile conversion

Layer / File(s) Summary
Git archive manifest resolution
pnpm/crates/resolving-git-resolver/..., pnpm/crates/tarball/..., pnpm/crates/package-manager/src/prefetching_resolver.rs, pnpm/crates/napi/src/resolve.rs
Git resolution optionally fetches package manifests from tarball archives, including manifests stored in archive subdirectories.
Fallible importer conversion
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs
Importer dependency parsing and lockfile construction now return structured errors with alias and dependency-path context.
Git package key generation and regression coverage
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs
Tests cover direct and renamed git-hosted dependencies, malformed dependency paths, and updated file-reference handling.
Fresh-install error propagation
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs, .changeset/git-importer-lockfile.md
Fresh lockfile creation maps conversion failures into the install error type and records a patch release.

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
Loading

Possibly related issues

  • pnpm/pnpm#13040: Directly covers the git-hosted dependency lockfile panic addressed by fallible parsing and regression tests.

Possibly related PRs

  • pnpm/pnpm#12076: Shares real_name and remote tarball handling in lockfile conversion.

Suggested labels: product: pacquet

Suggested reviewers: zkochan, zkochan

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

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.

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

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 win

Avoid 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 a real_name adds 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 win

Use 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_key is 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

📥 Commits

Reviewing files that changed from the base of the PR and between ca66b76 and 982aff8.

📒 Files selected for processing (4)
  • .changeset/git-importer-lockfile.md
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs

@greptile-apps

greptile-apps Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

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

Comments Outside Diff (1)

  1. pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs, line 449-458 (link)

    P1 real_name omits LockfileResolution::Git, so unaliased non-archive git deps write the wrong lockfile format

    LockfileResolution::Git(_) falls to _ => false, which means real_name returns None for any Git resolution (ssh URLs, git+file://, self-hosted repos). For an unaliased dep where alias == real_package_name, importer_dep_version then falls to dep_path_str.parse::<ImporterDepVersion>(). The dep path is my-package@git+file://...#abc123 (after build_pkg_id_with_patch_hash prepends the manifest name), so this parses as ImporterDepVersion::Alias("my-package", ...) and serializes to version: my-package@git+file://...#abc123. Upstream pnpm v11 writes the plain ref form — version: git+file://...#abc123 — for unaliased deps, reserving the name@ref alias form for renamed deps only.

    snapshot_dep_ref has the same gap: child Git nodes with alias == real_name would emit SnapshotDepRef::Alias instead of SnapshotDepRef::Plain, writing my-package: my-package@git+file://... in the snapshot's dependencies instead of my-package: git+file://....

    The PR validation table tests the Git fixture with an aliased dep (aliased-dep → my-real-pkg-name), which is correct for that case. Unaliased Git deps — a common pattern ("my-package": "git+ssh://github.com/user/repo.git") — are not exercised and would produce a lockfile that pnpm v11 interprets differently.

    Adding LockfileResolution::Git(_) => true to the reads_name_from_manifest match arm should fix both importer_dep_version and snapshot_dep_ref at once, since both call real_name and rely on its return value to strip the name@ prefix for unaliased deps.

Reviews (8): Last reviewed commit: "fix(git-fetcher): guard the repo argumen..." | Re-trigger Greptile

@codecov-commenter

codecov-commenter commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.44898% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.45%. Comparing base (e4d7a4a) to head (a1dbcfe).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
.../crates/resolving-git-resolver/src/git_resolver.rs 18.51% 44 Missing ⚠️
pnpm/crates/git-fetcher/src/fetcher.rs 92.59% 4 Missing ⚠️
...kage-manager/src/dependencies_graph_to_lockfile.rs 92.68% 3 Missing ⚠️
pnpm/crates/tarball/src/lib.rs 88.88% 3 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 6fef22db4a40

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.909 ± 0.124 2.715 3.101 1.74 ± 0.17
pacquet@main 3.005 ± 0.205 2.685 3.271 1.79 ± 0.20
pnpr@HEAD 1.676 ± 0.152 1.493 1.906 1.00
pnpr@main 1.727 ± 0.148 1.484 1.892 1.03 ± 0.13
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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 378.5 ± 49.4 299.5 457.4 1.13 ± 0.17
pacquet@main 378.1 ± 87.6 291.9 571.3 1.13 ± 0.27
pnpr@HEAD 341.3 ± 27.5 301.5 393.6 1.02 ± 0.11
pnpr@main 336.0 ± 22.8 303.9 368.5 1.00
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.039 ± 0.047 2.965 3.109 1.82 ± 0.18
pacquet@main 3.079 ± 0.077 2.976 3.206 1.84 ± 0.19
pnpr@HEAD 1.793 ± 0.111 1.630 1.928 1.07 ± 0.13
pnpr@main 1.674 ± 0.168 1.487 1.932 1.00
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.017 ± 0.116 0.807 1.145 2.84 ± 0.35
pacquet@main 0.932 ± 0.142 0.747 1.156 2.61 ± 0.41
pnpr@HEAD 0.358 ± 0.016 0.336 0.389 1.00
pnpr@main 0.360 ± 0.034 0.320 0.424 1.01 ± 0.11
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.246 ± 0.125 2.102 2.567 6.53 ± 0.59
pacquet@main 2.158 ± 0.075 2.062 2.297 6.27 ± 0.49
pnpr@HEAD 0.344 ± 0.024 0.310 0.384 1.00
pnpr@main 0.353 ± 0.029 0.282 0.389 1.03 ± 0.11
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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 485.7 ± 34.3 441.9 560.0 5.15 ± 0.55
pacquet@main 490.7 ± 54.2 429.5 603.9 5.20 ± 0.71
pnpr@HEAD 96.8 ± 4.0 89.2 105.4 1.03 ± 0.09
pnpr@main 94.3 ± 7.5 85.2 117.9 1.00
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.675 ± 0.198 4.556 5.140 1.23 ± 0.06
pacquet@main 4.733 ± 0.224 4.505 5.115 1.24 ± 0.06
pnpr@HEAD 3.814 ± 0.074 3.704 3.929 1.00
pnpr@main 3.957 ± 0.171 3.766 4.221 1.04 ± 0.05
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
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13059
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
3,039.32 ms
(-16.88%)Baseline: 3,656.72 ms
4,388.07 ms
(69.26%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,246.45 ms
(-13.30%)Baseline: 2,591.02 ms
3,109.22 ms
(72.25%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,016.99 ms
(-6.72%)Baseline: 1,090.22 ms
1,308.27 ms
(77.74%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
485.70 ms
(-9.32%)Baseline: 535.60 ms
642.72 ms
(75.57%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,908.84 ms
(-12.49%)Baseline: 3,324.16 ms
3,988.99 ms
(72.92%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,674.92 ms
(-22.24%)Baseline: 6,012.36 ms
7,214.83 ms
(64.80%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
378.53 ms
(-21.97%)Baseline: 485.09 ms
582.11 ms
(65.03%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13059
Testbedpnpr

⚠️ 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-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,793.43 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
343.96 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
357.60 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
96.79 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,675.70 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,813.55 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
341.25 ms
🐰 View full continuous benchmarking report in Bencher

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

2 similar comments
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 16, 2026
DebadityaHait and others added 4 commits July 16, 2026 22:14
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.
@zkochan
zkochan force-pushed the fix/git-dependency-lockfile-panic branch from 6fef22d to 3bbdd07 Compare July 16, 2026 21:28

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

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 win

Propagate 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 from packages and snapshots while 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6fef22d and 3bbdd07.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (8)
  • .changeset/git-importer-lockfile.md
  • pnpm/crates/napi/src/resolve.rs
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs
  • pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/resolving-git-resolver/Cargo.toml
  • pnpm/crates/resolving-git-resolver/src/git_resolver.rs
  • pnpm/crates/resolving-git-resolver/src/lib.rs

@zkochan zkochan changed the title fix(package-manager): handle git lockfile refs fix(resolving-git-resolver): read git package name during resolution Jul 16, 2026
@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (5) 📘 Rule violations (0) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. read_git_manifest lacks path guard ✓ Resolved 📘 Rule violation ⛨ Security ⭐ New
Description
read_git_manifest builds pkg_dir by stripping only a leading slash from query.path and then
joining it onto the temporary checkout, allowing .. segments (and platform-specific absolute
forms) like #path:/../escape to traverse outside the checkout and read arbitrary package.json
paths on the host filesystem. This creates a security risk (tainting resolved package identity) and
violates the containment/reuse expectations already enforced by the install pass’s guarded join
logic, leading to inconsistent behavior between resolve and install flows.
Code

pnpm/crates/git-fetcher/src/fetcher.rs[R289-295]

+        // The leading slash of `#path:/packages/foo` is rooted at the
+        // repo, not the filesystem — same normalization the install
+        // pass's `prepare_package` applies.
+        let pkg_dir = match query.path.map(|path| path.trim_start_matches(['/', '\\'])) {
+            Some(path) if !path.is_empty() => temp.path().join(path),
+            _ => temp.path().to_path_buf(),
+        };
Evidence
The resolve-time manifest reader constructs a filesystem path from untrusted query.path using
trim_start_matches followed by temp.path().join(...) without canonicalization or any “stays
under repo root” validation, so path traversal or absolute-path inputs can escape the checkout. In
contrast, the install-time helper explicitly documents and enforces a repo-rooted invariant and
rejects escapes (via safe_join_path), meaning the new resolve-time code duplicates the logic but
drops the security-relevant containment checks; additionally, because
safe_read_package_json_from_dir reads whichever directory it is given, any escaped pkg_dir
results directly in reading an arbitrary package.json outside the checkout.

AGENTS.md: Avoid Duplicated Implementations by Reusing or Extracting Shared Code
pnpm/crates/git-fetcher/src/fetcher.rs[289-295]
pnpm/crates/git-fetcher/src/prepare_package.rs[194-203]
pnpm/crates/git-fetcher/src/fetcher.rs[277-297]
pnpm/crates/package-manifest/src/lib.rs[701-714]
pnpm/crates/git-fetcher/src/prepare_package.rs[193-214]

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

## Issue description
`read_git_manifest` computes `pkg_dir` by trimming only a leading path separator from untrusted `query.path` and then calling `temp.path().join(path)` without any containment/root-escape validation. This enables traversal (e.g., `/../...` or `../..`) and platform-specific absolute path forms to escape the checkout and read `package.json` from arbitrary filesystem locations, which can taint resolved package identity and diverges from the install pass’s containment guarantees.

## Issue Context
The install pass already uses a guarded join (`safe_join_path`) that normalizes repo-rooted paths (stripping the leading slash) and rejects paths that climb outside the checkout; the resolve-time manifest read currently duplicates similar path handling but omits the canonicalization/starts-with checks, creating a security-relevant behavioral mismatch. Since `safe_read_package_json_from_dir` will read whatever directory it is given, ensuring `pkg_dir` is confined to the checkout is essential; consider factoring `safe_join_path` into a shared helper usable by both install and resolve paths to keep behavior consistent.

## Fix Focus Areas
- pnpm/crates/git-fetcher/src/fetcher.rs[277-297]
- pnpm/crates/git-fetcher/src/fetcher.rs[289-295]
- pnpm/crates/git-fetcher/src/prepare_package.rs[193-214]
- pnpm/crates/git-fetcher/src/prepare_package.rs[194-203]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Repo option injection ✓ Resolved 🐞 Bug ⛨ Security ⭐ New
Description
The new resolve-time checkout path (read_git_manifest → checkout_commit) passes an unvalidated
repo string directly as an argument to git clone / git remote add; if the repo value starts
with - it can be parsed as a git option (e.g. --upload-pack=...) and may result in executing
attacker-controlled commands. This risk existed for the install path previously, but this PR makes
it reachable during dependency resolution as well, widening the attack surface.
Code

pnpm/crates/git-fetcher/src/fetcher.rs[R230-237]

+    let git_bin = git_bin.unwrap_or_else(|| Path::new("git"));
+    if should_use_shallow(repo, git_shallow_hosts) {
+        exec_git_with(git_bin, &["init"], Some(dest))?;
+        exec_git_with(git_bin, &["remote", "add", "origin", repo], Some(dest))?;
+        exec_git_with(git_bin, &["fetch", "--depth", "1", "origin", commit], Some(dest))?;
+    } else {
+        exec_git_with(git_bin, &["clone", repo, &dest.to_string_lossy()], None)?;
+    }
Evidence
checkout_commit uses repo as a raw argv element for git clone/git remote add without an
option terminator, and the new resolve-time path calls it while building the resolve result.

pnpm/crates/git-fetcher/src/fetcher.rs[221-248]
pnpm/crates/resolving-git-resolver/src/git_resolver.rs[172-187]

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

### Issue description
`checkout_commit` forwards `repo` directly to git subcommands. If `repo` begins with `-`, git may treat it as an option (not a URL/path), enabling option-injection during the new resolve-time checkout.

### Issue Context
This path is newly invoked during resolution via `read_git_manifest` (from the git resolver), so it can execute earlier than the install pass.

### Fix Focus Areas
- Add end-of-options markers and/or validation
 - pnpm/crates/git-fetcher/src/fetcher.rs[221-248]
 - pnpm/crates/git-fetcher/src/fetcher.rs[277-297]
 - pnpm/crates/resolving-git-resolver/src/git_resolver.rs[172-187]

### Suggested fix
- For each git invocation that accepts a repository/URL positional, insert `--` before the repo argument where supported (e.g. `git clone -- <repo> <dest>`; `git remote add origin -- <repo>`).
- Additionally reject `repo` values starting with `-` (or containing NUL) and surface a structured error, to be robust even if some subcommand’s option parsing doesn’t honor `--` as expected.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Cache row mismatch ✓ Resolved 🐞 Bug ≡ Correctness
Description
FetchTarballForResolution can derive the store-index key from a subdirectory manifest
(manifest_subdir) but still queues the unmodified pkg_files_idx built from the archive root, so
the cached row is internally inconsistent (key says subpackage, payload describes repo root / whole
archive). This risks incorrect warm-store behavior for any consumer that trusts
PackageFilesIndex.manifest/files to match the key (e.g., bin linking and file materialization
decisions).
Code

pnpm/crates/tarball/src/lib.rs[R2503-2506]

+        let manifest = match manifest_subdir {
+            Some(subdir) => read_subdir_manifest(&cas_paths, subdir).await?,
+            None => pkg_files_idx.manifest.clone(),
+        };
Evidence
The code now swaps manifest based on manifest_subdir, but the queued pkg_files_idx remains the
extraction result that only captures the archive-root package.json and the full file map; for
git-hosted #path installs, the archive contains the whole monorepo, so reusing the whole-repo map
for a subpackage key is inconsistent.

pnpm/crates/tarball/src/lib.rs[2473-2532]
pnpm/crates/tarball/src/lib.rs[672-878]
pnpm/crates/git-fetcher/src/tarball_fetcher.rs[52-60]
pnpm/crates/git-fetcher/src/tarball_fetcher.rs[155-158]

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

### Issue description
When `manifest_subdir` is `Some`, `FetchTarballForResolution` selects a different manifest (`<subdir>/package.json`) for name/version purposes, but still queues the `PackageFilesIndex` produced by extraction of the archive root (root manifest + full file map). This creates a store-index row whose key and payload disagree.

### Issue Context
This affects git-hosted tarballs that use `#path:/...` (subpackage in a monorepo). In those cases the archive spans the whole repo, and the correct manifest is in the subdirectory, not at the archive root.

### Fix Focus Areas
- pnpm/crates/tarball/src/lib.rs[2503-2532]
- pnpm/crates/tarball/src/lib.rs[2535-2567]

### What to change
- Ensure the queued store-index row is consistent with the key when `manifest_subdir` is set. Options:
 1) **Skip queuing** a store-index row (and any mem-cache warm behavior) for `manifest_subdir != None`, since the extracted `pkg_files_idx`/`cas_paths` represent the whole repo and not the subpackage.
 2) Or **construct a subpackage-scoped `PackageFilesIndex`** (and corresponding `cas_paths`/files map) by filtering entries under the `manifest_subdir` prefix and setting `pkg_files_idx.manifest` to the subdir manifest before calling `writer.queue`.
- Add/adjust a regression test asserting that, when `manifest_subdir` is set, the queued `PackageFilesIndex.manifest` (and files) correspond to the same subpackage identity used to build the cache key.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. Changeset missing pnpm entry ✗ Dismissed 📘 Rule violation § Compliance
Description
The added changeset only bumps pacquet and does not declare a bump for the pnpm package. This
violates the requirement that changesets explicitly include pnpm with a valid bump type.
Code

.changeset/git-importer-lockfile.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires each changeset to include an explicit pnpm entry with a valid
bump type. The added changeset front-matter lists only pacquet: patch and omits pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/git-importer-lockfile.md[1-3]

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

## Issue description
The changeset front-matter does not include the `pnpm` package entry.

## Issue Context
Compliance requires that changeset files explicitly declare a bump for `pnpm` and that the bump type is one of `patch`/`minor`/`major`.

## Fix Focus Areas
- .changeset/git-importer-lockfile.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. Blocking checkout in resolver 🐞 Bug ☼ Reliability ⭐ New
Description
read_git_manifest performs a full git checkout inside tokio::task::block_in_place, which can
panic under a current-thread runtime and reduces resolver concurrency under load (each git dep can
occupy a runtime worker thread for long periods). This is now reachable during dependency resolution
via the git resolver.
Code

pnpm/crates/git-fetcher/src/fetcher.rs[R277-287]

+pub async fn read_git_manifest(
+    query: GitManifestQuery<'_>,
+) -> Result<Option<Value>, GitFetcherError> {
+    tokio::task::block_in_place(|| {
+        let temp = tempfile::tempdir().map_err(GitFetcherError::Io)?;
+        checkout_commit(&CheckoutOptions {
+            repo: query.repo,
+            commit: query.commit,
+            git_shallow_hosts: query.git_shallow_hosts,
+            git_bin: query.git_bin,
+            dest: temp.path(),
Evidence
The resolve-time helper uses block_in_place around git checkout work, and the git resolver calls
it during resolve() when fetch context is configured.

pnpm/crates/git-fetcher/src/fetcher.rs[277-298]
pnpm/crates/resolving-git-resolver/src/git_resolver.rs[128-187]

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

### Issue description
`read_git_manifest` wraps a long-running, blocking git clone/fetch/checkout inside `block_in_place`. This can panic on current-thread runtimes and can reduce throughput when resolving many git deps concurrently.

### Issue Context
This is invoked from `GitResolver::read_package_metadata` during resolution.

### Fix Focus Areas
- Avoid long work in `block_in_place`
 - pnpm/crates/git-fetcher/src/fetcher.rs[277-298]
 - pnpm/crates/resolving-git-resolver/src/git_resolver.rs[172-187]

### Suggested fix
- Switch to `tokio::task::spawn_blocking` (or a dedicated blocking pool) for the checkout + filesystem reads, returning the parsed manifest back into async context.
- Add backpressure/concurrency limiting if multiple git deps can resolve concurrently, to avoid spawning too many blocking threads.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Root path treated subdir 🐞 Bug ➹ Performance
Description
FetchTarballForResolution suppresses the store-index row whenever manifest_subdir is Some(_),
so git specifiers like ...#path:/ or ...#path: (which parse to Some("/") / Some("")) are
treated as subdirectory packages and lose resolve-time indexing even though they semantically mean
“root”. This can increase repeated downloads/extractions for those deps and may also lead to a
missing manifest because the code path won’t use the root manifest behavior.
Code

pnpm/crates/tarball/src/lib.rs[R2523-2541]

+        if manifest_subdir.is_none() {
+            // Scope the store-index row by the package's canonical
+            // `name@version`, matching what the install pass derives from
+            // the same manifest. Fall back to the URL when the tarball has
+            // no usable `package.json` name (degraded, but keeps the row
+            // addressable).
+            let package_id =
+                manifest_package_id(manifest.as_ref()).unwrap_or_else(|| package_url.to_string());
+
+            let index_key = store_index_key(&integrity.to_string(), &package_id);
+            if let Some(writer) = store_index_writer {
+                writer.queue(index_key, pkg_files_idx);
+            } else {
+                tracing::warn!(
+                    target: "pacquet::download",
+                    ?index_key,
+                    "no shared store-index writer; skipping index row for this resolve-time tarball",
+                );
+            }
Evidence
The store-index row is suppressed purely by manifest_subdir.is_none(), so any Some(_) value
disables indexing. Independently, git #path parsing stores the path: value verbatim (including
empty/root strings), making root-equivalent manifest_subdir values reachable from user input.

pnpm/crates/tarball/src/lib.rs[2512-2541]
pnpm/crates/resolving-git-resolver/src/parse_bare_specifier.rs[90-113]
pnpm/crates/resolving-git-resolver/src/parse_bare_specifier.rs[201-218]

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

### Issue description
`manifest_subdir.is_none()` is used as the sole gate for writing a resolve-time store-index row. If `manifest_subdir` is present but root-equivalent (e.g. `""` or `"/"` from a git specifier like `#path:` / `#path:/`), the code treats it as a subdirectory package and suppresses indexing, even though it should behave like the root.

### Issue Context
`parse_git_params` preserves the `path:` parameter verbatim, so empty/root values are possible. `FetchTarballForResolution` should defensively normalize these values at the boundary.

### Fix Focus Areas
- pnpm/crates/tarball/src/lib.rs[2507-2541]
- pnpm/crates/resolving-git-resolver/src/parse_bare_specifier.rs[90-113]

### Suggested fix
- In `FetchTarballForResolution::run`, normalize `manifest_subdir` before use:
 - Treat `Some(s)` as `None` when `s.trim_matches('/').is_empty()`.
 - Use the normalized value for both: (a) deciding whether to read a subdir manifest, and (b) deciding whether to write the store-index row.
- Add a regression test for `manifest_subdir: Some("/")` (and optionally `Some("")`) asserting it behaves like `None` (i.e., root manifest path, and index row is written).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Unbounded manifest reread 🐞 Bug ➹ Performance
Description
read_subdir_manifest reads the entire <subdir>/package.json back from disk (tokio::fs::read)
with no size limit, adding extra IO and a second full allocation for a file whose bytes were already
available during extraction. This is a measurable resolve-time overhead for #path git deps and
makes worst-case memory usage higher for unusually large manifests.
Code

pnpm/crates/tarball/src/lib.rs[R2550-2555]

+    let key = format!("{}/package.json", subdir.trim_matches('/'));
+    let Some(cas_path) = cas_paths.get(&key) else { return Ok(None) };
+    let bytes = tokio::fs::read(cas_path)
+        .await
+        .map_err(|source| TarballError::ReadLocalTarball { path: cas_path.clone(), source })?;
+    match serde_json::from_slice::<serde_json::Value>(&bytes) {
Evidence
The new helper reads the manifest from the CAS path by loading the whole file into a Vec<u8>,
while the extraction loop already has per-entry payload slices in memory and parses the root
package.json without an extra read/copy.

pnpm/crates/tarball/src/lib.rs[2543-2564]
pnpm/crates/tarball/src/lib.rs[703-812]

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

### Issue description
`read_subdir_manifest()` performs an unconditional whole-file `tokio::fs::read()` on `<subdir>/package.json` with no size cap, which adds redundant disk IO and allocations.

### Issue Context
During extraction, tar entries are already walked and their payload slices are available in memory. Root `package.json` is parsed directly from that in-memory slice; subdir manifests could be handled similarly to avoid the CAS round-trip.

### Fix Focus Areas
- pnpm/crates/tarball/src/lib.rs[2503-2506]
- pnpm/crates/tarball/src/lib.rs[2535-2567]
- pnpm/crates/tarball/src/lib.rs[672-833]

### What to change
- Prefer **capturing/parsing the subdir `package.json` during extraction** (tar/zip):
 - Compute the expected cleaned path for the subdir manifest (e.g. `packages/foo/package.json`) and when that entry is encountered, parse it from the in-memory entry payload (like the root path does).
 - Return/store that manifest without doing a disk read.
- If disk read is kept, enforce a **maximum manifest size** before reading/parsing (e.g., stat + reject/return `None` when above threshold, or stream-read with an upper bound) to avoid unbounded allocations.
- Keep behavior best-effort (parse failures should degrade to `None` as today).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
8. Offline gate missing for git fetch 🐞 Bug ⛨ Security
Description
GitResolver now downloads and extracts a git-hosted archive during resolution to populate
ResolveResult.manifest, but this code path has no offline/egress gate and will attempt
network+store writes whenever fetch_context is set. This can cause unexpected network egress and
failures in “offline” or “lockfile-only” style runs that previously avoided tarball extraction work
during resolution.
Code

pnpm/crates/resolving-git-resolver/src/git_resolver.rs[R106-147]

        let Some(bare) = wanted_dependency.bare_specifier.as_deref() else { return Ok(None) };
        let Some(partial) = parse_bare_specifier(bare) else { return Ok(None) };
        let spec = partial.finalize(self.probe.as_ref()).await;
-        let result =
+        let mut result =
            build_resolve_result(spec, self.runner.as_ref(), wanted_dependency.alias.as_deref())
                .await?;
+        result.manifest = self.fetch_manifest(&result).await?;
        Ok(Some(result))
    }

+    /// Read the `package.json` bundled in a git-hosted package's
+    /// archive. `None` whenever the name can't be sourced this way —
+    /// no fetch context (unit tests / resolve-only callers), or a
+    /// non-hosted repo that needs a clone rather than an archive
+    /// download.
+    async fn fetch_manifest(
+        &self,
+        result: &ResolveResult,
+    ) -> Result<Option<Arc<serde_json::Value>>, ResolveError> {
+        let Some(ctx) = self.fetch_context.as_ref() else { return Ok(None) };
+        let LockfileResolution::Tarball(tarball) = &result.resolution else { return Ok(None) };
+
+        // Silent reporter: the install pass owns the
+        // `resolved → found_in_store → imported` event ordering.
+        let resolved = FetchTarballForResolution {
+            http_client: &ctx.http_client,
+            store_dir: ctx.store_dir,
+            store_index_writer: ctx.store_index_writer.clone(),
+            package_url: &tarball.tarball,
+            // A git host's archive URL is the package's only identifier
+            // at this point — its name is what this fetch is here to
+            // learn — and such archives carry no scoped-registry auth.
+            package_id: &tarball.tarball,
+            auth_headers: &ctx.auth_headers,
+            retry_opts: ctx.retry_opts,
+        }
+        .run::<SilentReporter>(None)
+        .await
+        .map_err(|err| Box::new(err) as ResolveError)?;
+
+        Ok(resolved.manifest.map(Arc::new))
+    }
Evidence
The PR adds a resolve-time manifest fetch for git-hosted tarball resolutions and enables it in the
fresh-install resolver chain. The tarball helper used by this path performs a full download+extract
and is not parameterized by offline, so it cannot respect offline/no-side-effect intent.

pnpm/crates/resolving-git-resolver/src/git_resolver.rs[100-147]
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs[681-696]
pnpm/crates/tarball/src/lib.rs[2447-2492]
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs[1362-1367]

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

## Issue description
`GitResolver::fetch_manifest` triggers `FetchTarballForResolution` during *resolution* whenever `fetch_context` is present. Unlike the install-time tarball fetchers, this resolve-time fetch API has no `offline` gating, so it will attempt network I/O and extract/write to the store even when the caller intends to avoid such side effects.

## Issue Context
- The fresh-install path wires `GitResolver` with a `GitFetchContext`, so resolving git-hosted tarball deps will now invoke `FetchTarballForResolution`.
- `FetchTarballForResolution` always runs the download+extract pipeline; it is not designed to honor `offline` or “no store writes” modes.

## Fix Focus Areas
- pnpm/crates/resolving-git-resolver/src/git_resolver.rs[100-147]
- pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs[681-696]
- pnpm/crates/tarball/src/lib.rs[2447-2520]

## How to fix
1. Extend `GitFetchContext` to carry the relevant policy knobs (at least `offline: bool`; optionally a flag indicating whether store writes are allowed).
2. In `fetch_manifest`, enforce the policy before invoking `FetchTarballForResolution`:
  - If `offline` is true, either:
    - return `Ok(None)` and let downstream keep the manifest-less shape, **or**
    - return a structured resolve error explaining that git-hosted deps require an online archive fetch to learn the package name.
3. If “lockfile-only / dry-run should not touch store” is a desired contract, avoid extraction/store writes in this path (see performance finding for possible lightweight alternatives).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Git resolution extracts whole tarball 🐞 Bug ➹ Performance
Description
The new git-hosted manifest fetch uses FetchTarballForResolution, which downloads and fully
extracts the archive and writes a store-index row during resolution even though the git-hosted
install path uses git_hosted_store_index_key + GitHostedTarballFetcher. This adds potentially
substantial extra work and store writes per git dependency, and the install path cannot directly
reuse the resolve-time store-index keying scheme.
Code

pnpm/crates/resolving-git-resolver/src/git_resolver.rs[R128-147]

+        // Silent reporter: the install pass owns the
+        // `resolved → found_in_store → imported` event ordering.
+        let resolved = FetchTarballForResolution {
+            http_client: &ctx.http_client,
+            store_dir: ctx.store_dir,
+            store_index_writer: ctx.store_index_writer.clone(),
+            package_url: &tarball.tarball,
+            // A git host's archive URL is the package's only identifier
+            // at this point — its name is what this fetch is here to
+            // learn — and such archives carry no scoped-registry auth.
+            package_id: &tarball.tarball,
+            auth_headers: &ctx.auth_headers,
+            retry_opts: ctx.retry_opts,
+        }
+        .run::<SilentReporter>(None)
+        .await
+        .map_err(|err| Box::new(err) as ResolveError)?;
+
+        Ok(resolved.manifest.map(Arc::new))
+    }
Evidence
The new code path uses FetchTarballForResolution (full extract + integrity-keyed store index) to
get a manifest during resolution, but the git-hosted install path uses a separate git-hosted
store-index key and fetcher. This means the resolve-time work is extra and not naturally reused by
the git-hosted materialization fast path.

pnpm/crates/resolving-git-resolver/src/git_resolver.rs[121-147]
pnpm/crates/tarball/src/lib.rs[2447-2511]
pnpm/crates/package-manager/src/install_package_by_snapshot.rs[418-456]

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

## Issue description
`GitResolver::fetch_manifest` currently calls `FetchTarballForResolution`, which performs the full download → integrity → extract-to-store pipeline. For git-hosted tarballs, the install/materialization path uses a different store-index key shape (`git_hosted_store_index_key`) and a different fetcher (`GitHostedTarballFetcher`), so this resolve-time extraction does not obviously enable a warm fast-path and can amount to an extra archive download/extract per git dependency.

## Issue Context
- This resolve-time fetch is used to learn the canonical package name from `package.json` for git-hosted deps so lockfile keys are correct.
- The current implementation explicitly passes `mem_cache: None`, and the store-index row is keyed by `store_index_key(integrity, package_id)` inside `FetchTarballForResolution`.
- Git-hosted materialization routes through `GitHostedTarballFetcher` and uses `git_hosted_store_index_key(pkg_id, built)`.

## Fix Focus Areas
- pnpm/crates/resolving-git-resolver/src/git_resolver.rs[121-147]
- pnpm/crates/tarball/src/lib.rs[2447-2519]
- pnpm/crates/package-manager/src/install_package_by_snapshot.rs[418-456]

## How to fix
Pick one of these directions (in increasing scope):
1. **Manifest-only fetch (preferred):** implement a lightweight helper that fetches/parses just `package.json` from the archive (or a small subset), without extracting the whole tarball into the CAS/store index.
2. **Keying alignment:** if resolve-time extraction is kept, write any store-index metadata under the same git-hosted key scheme the install path uses (e.g., the `git_hosted_store_index_key` shape for `built=false`), so install can reuse it.
3. **Explicitly suppress store-index writes:** if you only need the manifest, avoid queueing store-index rows in this path to reduce store churn.

Also consider threading an optional mem-cache/shared extraction handle if there is a safe way to reuse work without breaking the git-hosted prepare/packlist behavior in the install pass.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread .changeset/git-importer-lockfile.md Resolved
@qodo-code-review

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to a1dbcfe

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

CategorySuggestion                                                                                                                                    Impact
Possible issue
Handle plain git manifest names

Add LockfileResolution::Git(_) to the reads_name_from_manifest match to
correctly extract the package name.

pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs [449-453]

 let reads_name_from_manifest = match &result.resolution {
-    LockfileResolution::Variations(_) => true,
+    LockfileResolution::Git(_) | LockfileResolution::Variations(_) => true,
     LockfileResolution::Tarball(tarball) => is_remote_http_tarball(&tarball.tarball),
     _ => false,
 };
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: This fixes a bug where LockfileResolution::Git was omitted from reads_name_from_manifest, successfully aligning the code with the updated comment and ensuring proper name extraction for plain git dependencies.

High
  • More

Previous suggestions

Suggestions up to commit af3bd4d
CategorySuggestion                                                                                                                                    Impact
Security
Prevent manifest path traversal

Expose and reuse safe_join_path to validate the query.path subdirectory.

pnpm/crates/git-fetcher/src/fetcher.rs [292-296]

-let pkg_dir = match query.path.map(|path| path.trim_start_matches(['/', '\\'])) {
-    Some(path) if !path.is_empty() => temp.path().join(path),
-    _ => temp.path().to_path_buf(),
-};
+let pkg_dir = safe_join_path(temp.path(), query.path)
+    .map_err(GitFetcherError::Prepare)?;
 safe_read_package_json_from_dir(&pkg_dir).map_err(GitFetcherError::ReadManifest)
Suggestion importance[1-10]: 9

__

Why: This is an important security fix that prevents path traversal and symlink escape vulnerabilities when reading a git-hosted package's manifest.

High
Suggestions up to commit 023b2be
CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid indexing raw repository archives

Remove store_index_writer from GitFetchContext to prevent raw git archives from
being incorrectly indexed as installable packages.

pnpm/crates/resolving-git-resolver/src/git_resolver.rs [40-46]

 pub struct GitFetchContext {
     pub http_client: Arc<ThrottledClient>,
     pub store_dir: &'static StoreDir,
-    pub store_index_writer: Option<Arc<StoreIndexWriter>>,
     pub auth_headers: Arc<AuthHeaders>,
     pub retry_opts: RetryOpts,
 }
Suggestion importance[1-10]: 9

__

Why: Removing the store-index writer from GitFetchContext correctly prevents cache poisoning where raw git repository archives could overwrite canonical name@version cache entries.

High
Prevent unprepared package cache entries

Disable store-index persistence for the manifest-only fetch by setting
store_index_writer to None.

pnpm/crates/resolving-git-resolver/src/git_resolver.rs [133]

-store_index_writer: ctx.store_index_writer.clone(),
+store_index_writer: None,
Suggestion importance[1-10]: 9

__

Why: Passing None for the store-index writer ensures that raw, unprepared git archives aren't incorrectly persisted to the package store index.

High
Isolate manifest-only archive fetching

Stop passing store_index_writer when initializing GitFetchContext in the install
pass.

pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs [693]

-store_index_writer: Some(Arc::clone(&store_index_writer)),
 
+
Suggestion importance[1-10]: 9

__

Why: Avoiding the injection of store_index_writer into the git resolver guarantees that the manifest-only fetch does not mistakenly index raw git repositories.

High
Suggestions up to commit 3bbdd07
CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid caching incomplete git packages

Pass None for store_index_writer to prevent caching the raw git archive.

pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs [690-696]

 .with_fetch_context(GitFetchContext {
     http_client: Arc::clone(&http_client_arc),
     store_dir,
-    store_index_writer: Some(Arc::clone(&store_index_writer)),
+    store_index_writer: None,
     auth_headers: Arc::clone(&auth_headers),
     retry_opts: crate::retry_config::retry_opts_from_config(config),
 });
Suggestion importance[1-10]: 5

__

Why: Passing None for store_index_writer correctly avoids caching incomplete git package extractions, preventing potential cache poisoning where the raw archive is used instead of the prepared package.

Low

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.
Comment thread pnpm/crates/tarball/src/lib.rs Resolved
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 023b2be

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pacquet: pnpm install panics building lockfile for git-hosted deps ("always parse as PkgNameVerPeer")

3 participants