Repository navigation
Conversation
…olve time A `file:*.tgz` dependency's name, version, and dependencies live only in the archive's own `package.json`. The local resolver left `manifest` unset for the tarball branch, so `build_pkg_id_with_patch_hash` had no name to prefix and emitted the bare `file:<path>` as the dep path. That parses as no lockfile key, and `build_packages_and_snapshots` dropped it with a silent `continue` — the install reported success while writing no `packages:` / `snapshots:` row and linking a dangling symlink into a virtual-store directory that was never created. Read the archive during resolution, as the tarball resolver already does for remote tarballs and the git resolver for git deps: `pacquet-tarball` grows `read_local_tarball_metadata`, which hashes the file and reads its bundled `package.json` in one pass, replacing the resolver's hash-only read. Nothing is written to the store — the install pass addresses a `file:` tarball's store-index row by its `<name>@file:<path>` dep path, not by the `<name>@<version>` a resolve-time extraction could key, so such a row would never be read. With the name in scope the dep path becomes `<name>@file:<path>`, both lockfile blocks are emitted, the tarball's own dependencies are walked (they were dropped entirely before), and the install summary prints the version instead of the raw specifier. The lockfile is byte-identical to pnpm 11's for the same manifest. Harden the drop site too: `build_packages_and_snapshots` now errors on a dep path that keys no row instead of skipping it, so the next resolver gap surfaces at its source rather than as an install that exits 0 over a broken `node_modules`. `link:` deps are exempt — pnpm writes no row for one either. pnpm 11 already handles `file:` tarballs correctly (it reads the manifest from the fetch, and resolves and fetches together), so this needs no TypeScript counterpart. Closes #13379.
|
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:
📝 WalkthroughWalkthroughLocal ChangesLocal tarball installation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant LocalResolver
participant TarballMetadata
participant LockfileInstaller
CLI->>LocalResolver: resolve local file tarball
LocalResolver->>TarballMetadata: read_local_tarball_metadata(path)
TarballMetadata-->>LocalResolver: integrity and bundled manifest
LocalResolver-->>LockfileInstaller: local resolve result
LockfileInstaller->>LockfileInstaller: record packages and snapshots
LockfileInstaller->>LockfileInstaller: extract and link virtual-store package
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 |
PR Summary by QodoFix local
AI Description
Diagram
High-Level Assessment
Files changed (11)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains, and the previous documentation concern has been addressed by retaining only non-obvious architectural and test rationale. Reviews (6): Last reviewed commit: "fix(resolving-local-resolver): reject an..." | Re-trigger Greptile |
Micro-Benchmark ResultsLinux |
Code Review by Qodo
Context used✅ Compliance rules (platform):
32 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13409 +/- ##
==========================================
+ Coverage 87.55% 87.57% +0.02%
==========================================
Files 544 544
Lines 93464 93557 +93
==========================================
+ Hits 81832 81937 +105
+ Misses 11632 11620 -12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`read_bundled_manifest` read `package.json` through the tar entry with `read_to_end`, sizing a fresh allocation from the archive's own header. The reader is seekable over an in-memory buffer, so the bytes are already there: slice them instead, the way the extraction path beside it already does. Extract that offset/size arithmetic — which both call sites need, with the same three bounds checks — into `tar_entry_payload`. Defer the `build_packages_and_snapshots` hardening to its own change. Erroring on a dep path that keys no lockfile row is only correct once pacquet grows pnpm's `getManifestFromResponse` fallback: without it, a tarball carrying no `package.json` at all — which pnpm installs as `<alias>@file:<path>` with `version: 0.0.0` — would start failing closed. Both halves are tracked in #13410. Drop the backward-looking prose from the new tests, per the review guidance that a comment describes what the code asserts now.
|
Thanks — responses to the three findings. 1. Historical comment in module header — fixed in d559849. The module doc was narrating implementation history and repeating what the test names and assertions already state; trimmed to the one non-obvious point (why the manifest is read at resolve time rather than at fetch time), and reworded the per-test prose to describe what is asserted now. Same finding as Greptile's. 2. Unbounded tarball inflate read — partly fixed in d559849. The The gzip-bomb half I have not bounded, deliberately. 3. Changeset missing
This PR is Rust-only — pnpm 11 already handles Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit d559849 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
A `file:` tarball's `package.json` is the only thing that names the
package, and the name is what gives its dep path the `<name>@` prefix a
lockfile key parses. Degrading an unparsable one to `None` — which is
right for the extraction path, where install-side consumers re-read from
disk — silently reproduces the bug this branch fixes: no `packages:` /
`snapshots:` row, and a dangling symlink off an install that exits 0.
pnpm rejects the same tarball with `ERR_PNPM_TARBALL_EXTRACT`
("Failed to add tarball from ... to store: <parse error>"), so raise the
matching code and message. An archive carrying no `package.json` at all
stays a tolerated shape, since pnpm installs that one.
Reported by Qodo on #13409.
|
Re: Manifest parse error hidden — correct finding, fixed in 9b9d6d4. I checked it against pnpm 11 before changing anything, with a tarball whose pacquet, meanwhile, printed
One case stays tolerated: an archive with no Both new behaviours have tests ( Written by an agent (Claude Code, claude-opus-5). |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pnpm/crates/tarball/src/lib.rs (1)
2735-2750: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse regular comments only for the necessary internal invariant.
pnpm/crates/tarball/src/lib.rs#L2735-L2750: replace private-function rustdoc with a concise//invariant.pnpm/crates/tarball/src/tests.rs#L1334-L1336: use a regular rationale comment or remove it.pnpm/crates/tarball/src/tests.rs#L1354-L1356: use a regular rationale comment or remove it.pnpm/crates/tarball/src/tests.rs#L1369-L1369: remove the helper’s behavior-narrating rustdoc.As per coding guidelines, rustdoc is for public API contracts and regular comments are for implementation rationale; as per path instructions, comments must not narrate function bodies or duplicate test behavior.
🤖 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/tarball/src/lib.rs` around lines 2735 - 2750, Replace the private-function rustdoc near the tarball entry extraction logic in pnpm/crates/tarball/src/lib.rs:2735-2750 with a concise regular comment containing only the necessary internal invariant. In pnpm/crates/tarball/src/tests.rs:1334-1336 and 1354-1356, replace the rustdoc with brief rationale comments or remove them; at pnpm/crates/tarball/src/tests.rs:1369, remove the helper’s behavior-narrating rustdoc. Do not alter function behavior or duplicate test implementation details.Sources: Coding guidelines, 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/tarball/src/lib.rs`:
- Around line 2771-2774: Update the bundled manifest traversal around
parse_manifest_bytes and normalize_bundled_manifest to retain the payload of the
last matching package.json entry without parsing each entry immediately, then
parse and normalize only that final payload after traversal. Preserve
last-entry-wins behavior so malformed earlier duplicates do not fail when
superseded by a valid later entry, and add a regression test covering
malformed-then-valid duplicates.
---
Nitpick comments:
In `@pnpm/crates/tarball/src/lib.rs`:
- Around line 2735-2750: Replace the private-function rustdoc near the tarball
entry extraction logic in pnpm/crates/tarball/src/lib.rs:2735-2750 with a
concise regular comment containing only the necessary internal invariant. In
pnpm/crates/tarball/src/tests.rs:1334-1336 and 1354-1356, replace the rustdoc
with brief rationale comments or remove them; at
pnpm/crates/tarball/src/tests.rs:1369, remove the helper’s behavior-narrating
rustdoc. Do not alter function behavior or duplicate test implementation
details.
🪄 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: c70c2892-ca57-4532-bd1e-21277dfea269
📒 Files selected for processing (2)
pnpm/crates/tarball/src/lib.rspnpm/crates/tarball/src/tests.rs
|
Code review by qodo was updated up to the latest commit 9b9d6d4 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
The test bound an ephemeral port, dropped it, and pointed the registry at it, assuming nothing would claim it in between — its own comment conceded the port was only "(very likely)" free. Under a full-workspace run the suite's mockito servers bind ephemeral ports throughout, so the freed port can be taken before the request goes out; the connect then succeeds and the assertion fails. Seen once locally at 7323 tests. Point it at port 0 instead, which is never a listening port, so the connect is refused outright and the `is_connect()` branch is reached deterministically.
Reading the bundled manifest puts the archive's own `name` into the dep path and, from there, into a `node_modules/<name>` directory. An invalid one breaks both: `evil@name` yields the dep path `evil@name@file:<path>`, which parses back out as the unrelated package `evil` and links a dangling symlink, while a traversal or reserved name would place the package outside its slot. pnpm refuses these with `ERR_PNPM_INVALID_DEPENDENCY_NAME`. Validate the name with the repo's existing `is_valid_old_npm_package_name` — the same rule `pacquet-lockfile-verification` applies to lockfile-controlled names — before it reaches either consumer, and raise that code. Reported by Qodo on #13409.
|
Re: Tarball name not validated — real, and worse than "can't parse". Fixed in e8bed10. Checked against pnpm 11 first. pnpm refuses both shapes with
The whitespace case was already caught downstream, which is why only the packages:
evil@name@file:bad-1.0.0.tgz:
resolution: {integrity: sha512-..., tarball: file:bad-1.0.0.tgz}
version: 1.0.0...a dangling symlink into a directory named after the mis-parsed name. And this PR is what makes it reachable — before it, a
I also took CodeRabbit's adjacent request and added Full suite: 7324 passing. Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit e8bed10 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…cies (pnpm#13409) A `file:*.tgz` dependency's name, version, and dependencies live only in the archive's own `package.json`. The local resolver left `manifest` unset for the tarball branch, so `build_pkg_id_with_patch_hash` had no name to prefix and emitted the bare `file:<path>` as the dep path. That parses as no lockfile key, and `build_packages_and_snapshots` dropped it with a silent `continue` — the install reported success while writing no `packages:` / `snapshots:` row and linking a dangling symlink into a virtual-store directory that was never created. Read the archive during resolution, as the tarball resolver already does for remote tarballs and the git resolver for git deps: `pacquet-tarball` grows `read_local_tarball_metadata`, which hashes the file and reads its bundled `package.json` in one pass, replacing the resolver's hash-only read. Nothing is written to the store — the install pass addresses a `file:` tarball's store-index row by its `<name>@file:<path>` dep path, not by the `<name>@<version>` a resolve-time extraction could key, so such a row would never be read. With the name in scope the dep path becomes `<name>@file:<path>`, both lockfile blocks are emitted, the tarball's own dependencies are walked (they were dropped entirely before), and the install summary prints the version instead of the raw specifier. The lockfile is byte-identical to pnpm 11's for the same manifest. The manifest is borrowed out of the decompressed archive buffer rather than read through the tar entry, so an entry header can't size an allocation; the offset/size arithmetic both call sites need is extracted into `tar_entry_payload`. Reading the manifest puts its `name` into the dep path and into a `node_modules/<name>` directory, so the shapes that used to fail silently are refused the way pnpm refuses them: a `package.json` that isn't valid JSON raises `ERR_PNPM_TARBALL_EXTRACT`, one that names no package raises `ERR_PNPM_MISSING_PACKAGE_NAME`, and one whose name isn't a valid npm name raises `ERR_PNPM_INVALID_DEPENDENCY_NAME`. Degrading to "no manifest" is right for the extraction path, whose consumers re-read from disk, but here the manifest is the package's only source of identity, so clearing it reproduces the bug above. An archive with no `package.json` at all stays tolerated, matching pnpm, which synthesizes a name from the alias. Telling that apart from a nameless manifest needs more than a `None`, so the reader reports whether a root `package.json` was present. pnpm 11 already handles `file:` tarballs correctly (it reads the manifest from the fetch, and resolves and fetches together), so this needs no TypeScript counterpart. Closes pnpm#13379.
Summary
A
file:*.tgzdependency installed as a no-op:pnpm installexited 0, wrote nopackages:/snapshots:entry, and leftnode_modules/<name>as a dangling symlink into a virtual-store directory that was never created.The name, version, and dependencies of a local tarball live only inside the archive's own
package.json. The local resolver'sfile:branch returnedmanifest: None, sobuild_pkg_id_with_patch_hashhad no name to prefix and emitted the barefile:<path>as the dep path. That parses as no lockfile key, andbuild_packages_and_snapshotsdropped the node with a silentcontinue— while the importer entry, which takes a differentfile:-prefixed path, was still written.The resolver now reads the archive during resolution, the way the tarball resolver already does for remote tarballs and the git resolver for git deps.
pacquet-tarballgrowsread_local_tarball_metadata, which hashes the file and reads its bundledpackage.jsonin one pass, replacing the resolver's hash-only read — so it costs no extra file read. Nothing is written to the store: the install pass addresses afile:tarball's store-index row by its<name>@file:<path>dep path, not by the<name>@<version>a resolve-time extraction could key, so such a row would never be read.With the name in scope the dep path becomes
<name>@file:<path>, both lockfile blocks are emitted, the tarball's own dependencies are walked (they were dropped entirely before), and the install summary prints the version instead of the raw specifier. Verified against pnpm 11 on the issue's fixture and on a tarball with a registry dependency — the lockfiles are byte-identical.Reading the manifest means its
namenow flows into the dep path and into anode_modules/<name>directory, so the shapes that used to fail silently are refused the way pnpm refuses them:package.jsonERR_PNPM_TARBALL_EXTRACT{},[1,2],null,{"name":""}, version-only)ERR_PNPM_MISSING_PACKAGE_NAMEevil@name,../escape,node_modules)ERR_PNPM_INVALID_DEPENDENCY_NAMEEach was verified against pnpm 11 first. The
evil@namecase mattered most: it produced the dep pathevil@name@file:<path>, which parses back out as the unrelated packageeviland links a dangling symlink — reachable only because this PR is what first puts an archive-controlled name into the dep path.An archive carrying no
package.jsonat all stays tolerated, since pnpm installs that one by synthesizing a name from the alias.pnpm 11 already handles
file:tarballs correctly — it reads the manifest from the fetch, and resolves and fetches together — so this needs no TypeScript counterpart.Closes #13379.
On the silent
continueThe issue suggests hardening
build_packages_and_snapshotsto error rather than drop an unparsable dep path. I drafted that and pulled it back out: it is only correct once pacquet grows pnpm'sgetManifestFromResponsefallback. A tarball carrying nopackage.jsonat all still has no name to key a row by, and pnpm installs that case — synthesizing{ name: <alias>, version: '0.0.0' }— where the hardening alone would fail closed. Both halves are tracked together in #13410.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.
Written by an agent (Claude Code, claude-opus-5).