Skip to content

fix(package-manifest): read package.json files that start with a UTF-8 BOM - #13327

Merged
zkochan merged 2 commits into
mainfrom
fix/bom-package-json
Jul 25, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix/bom-package-json

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

serde_json rejects a leading UTF-8 byte order mark, so any package.json carrying one failed to parse with expected value at line 1 column 1. During workspace discovery that aborted the whole command, which made pnpm 12 unusable in repositories that keep such a manifest on purpose — vitejs/vite ships playground/resolve/utf8-bom-package/package.json and matches it with its workspace patterns.

Every manifest parse now goes through parse_manifest / parse_manifest_bytes, which drop a leading BOM first. The TypeScript CLI already decodes manifests through strip-bom (project manifests, cafs) and load-json-file's TextDecoder (dependency manifests), so this is a pacquet-only fix that brings the two stacks back in line — no TypeScript counterpart is needed.

Covered read paths: project manifests (workspace discovery), safe_read_package_json_from_dir (lifecycle scripts, directory fetcher), bin linking (pacquet-cmd-shim and pacquet-package-manager::link_bins), dependency pruning, global packages, virtual-store build detection, pnpm list / why manifest reads including the CAFS lookup, the package.json bundled inside a tarball and in an archive subdirectory (pnpm's addFilesFromTarball strips a BOM there too), pnpm publish <tarball>, and the packageManager / dlx / pack --app / stage / self-update / pnpm with manifest reads. package.yaml already tolerated a BOM; a test now pins that.

Extraction alone was not enough: a BOM-prefixed dependency manifest extracted fine but then failed bin linking with ParseManifest, which would have broken the install anyway. pacquet-cmd-shim and pacquet-publish gained a dependency on pacquet-package-manifest for the shared helpers.

Reading a BOM-prefixed manifest never rewrites the file on its own, so the BOM survives until a real change makes the writer emit the manifest afresh — the same as what pnpm writes.

Also, a manifest that really is malformed now reports its path. The reported diagnostic was four repetitions of expected value at line 1 column 1 with no indication of which file was at fault.

Reproduction from the issue, with this branch built:

$ pnpm list --recursive --depth 0 --json
[
  { "path": ".../bom-workspace", "private": false },
  { "name": "fixture", "version": "1.0.0", "path": ".../bom-workspace/packages/fixture", "private": false }
]

Closes #13311

Squash Commit Body

serde_json rejects a leading byte order mark, so a manifest carrying one
failed the whole read with "expected value at line 1 column 1". Workspace
discovery aborted on it, which made pnpm 12 unusable in repositories that
keep such a manifest on purpose — vitejs/vite ships
playground/resolve/utf8-bom-package/package.json and matches it with its
workspace patterns.

Route every manifest parse through parse_manifest / parse_manifest_bytes,
which drop the BOM first. pnpm decodes manifests through strip-bom and
TextDecoder, so both stacks now accept the same files: project manifests,
dependency manifests read from node_modules, and the package.json bundled
in a tarball. The BOM only disappears from a file once a real change makes
the writer emit the manifest afresh.

A manifest that really is malformed now reports its path, which the
workspace-discovery diagnostic previously omitted.

Closes pnpm/pnpm#13311

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.

Written by an agent (Claude Code, claude-opus-5[1m]).

…8 BOM

serde_json rejects a leading byte order mark, so a manifest carrying one
failed the whole read with "expected value at line 1 column 1". Workspace
discovery aborted on it, which made pnpm 12 unusable in repositories that
keep such a manifest on purpose — vitejs/vite ships
playground/resolve/utf8-bom-package/package.json and matches it with its
workspace patterns.

Route every manifest parse through parse_manifest / parse_manifest_bytes,
which drop the BOM first. pnpm decodes manifests through strip-bom and
TextDecoder, so both stacks now accept the same files: project manifests,
dependency manifests read from node_modules, and the package.json bundled
in a tarball. The BOM only disappears from a file once a real change makes
the writer emit the manifest afresh.

A manifest that really is malformed now reports its path, which the
workspace-discovery diagnostic previously omitted.

Closes #13311
Copilot AI review requested due to automatic review settings July 25, 2026 11:32

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b144ffa-643b-4c6f-bbf2-47f6f4cf949f

📥 Commits

Reviewing files that changed from the base of the PR and between 595856d and ef92260.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (18)
  • .changeset/read-bom-prefixed-manifests.md
  • pnpm/crates/cli/src/cli_args/deps_tree/finders.rs
  • pnpm/crates/cli/src/cli_args/dlx.rs
  • pnpm/crates/cli/src/cli_args/pack_app.rs
  • pnpm/crates/cli/src/cli_args/package_manager.rs
  • pnpm/crates/cli/src/cli_args/self_update/install_pnpm.rs
  • pnpm/crates/cli/src/cli_args/stage/summarize_tarball.rs
  • pnpm/crates/cli/src/cli_args/with/install_pnpm_to_store.rs
  • pnpm/crates/cmd-shim/Cargo.toml
  • pnpm/crates/cmd-shim/src/link_bins.rs
  • pnpm/crates/cmd-shim/src/link_bins/tests.rs
  • pnpm/crates/executor/src/lifecycle/tests.rs
  • pnpm/crates/package-manager/src/link_bins.rs
  • pnpm/crates/package-manager/src/prune_direct_deps.rs
  • pnpm/crates/publish/Cargo.toml
  • pnpm/crates/publish/src/extract_manifest_from_packed.rs
  • pnpm/crates/publish/src/extract_manifest_from_packed/tests.rs
  • pnpm/crates/tarball/src/lib.rs
📝 Walkthrough

Walkthrough

Changes

Manifest parsing and consumers

Layer / File(s) Summary
Shared parser and path-aware errors
pnpm/crates/package-manifest/src/lib.rs
Manifest loading now strips a leading UTF-8 BOM, exposes shared string/byte parsers, and includes the manifest path in parse errors.
Shared parser integration
pnpm/crates/cli/..., pnpm/crates/global/src/lib.rs, pnpm/crates/package-manager/src/create_virtual_store.rs, pnpm/crates/tarball/src/lib.rs
CLI, global, package-manager, and tarball manifest reads use the BOM-aware helpers while retaining existing fallback behavior.
BOM and error behavior validation
pnpm/crates/package-manifest/src/tests.rs, pnpm/crates/workspace/..., pnpm/crates/tarball/src/tests.rs, pnpm/crates/executor/src/lifecycle/tests.rs, .changeset/read-bom-prefixed-manifests.md
Tests cover BOM-prefixed manifests, tarball extraction, workspace discovery, save behavior, and path-aware malformed-manifest errors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WorkspaceDiscovery
  participant PackageManifest
  participant parse_manifest_bytes
  participant SerdeJson
  WorkspaceDiscovery->>PackageManifest: Read package.json bytes
  PackageManifest->>parse_manifest_bytes: Parse manifest bytes
  parse_manifest_bytes->>SerdeJson: Parse BOM-stripped JSON
  SerdeJson-->>parse_manifest_bytes: Manifest value or parse error
  parse_manifest_bytes-->>PackageManifest: Parsed manifest
  PackageManifest-->>WorkspaceDiscovery: Discovered project or path-aware error
Loading

Assessment against linked issues

Objective Addressed Explanation
Accept leading UTF-8 BOMs during workspace discovery and manifest loading [#13311] ✅
Include the offending manifest path in malformed-manifest errors [#13311] ✅

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bom-package-json

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix BOM-prefixed package.json parsing across pacquet manifest reads

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Strip a leading UTF-8 BOM before parsing any package.json (text or bytes).
• Route manifest parsing through shared helpers and improve parse errors with file paths.
• Add regression tests for workspace discovery, tarballs, and BOM preservation behavior.
Diagram

graph TD
  Workspace["Workspace discovery"] --> Manifest["package-manifest: parse_manifest*" ] --> Serde["serde_json"]
  Cli["CLI deps tree readers"] --> Manifest
  Global["Global package reader"] --> Manifest
  VStore["Virtual store build check"] --> Manifest
  Tarball["Tarball extractor"] --> Manifest
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Strip BOM at I/O boundaries only (read helpers)
  • ➕ Keeps parsing API surface smaller (no new parse helpers)
  • ➕ Limits BOM logic to a few centralized file-read functions
  • ➖ Harder to guarantee coverage for non-file sources (e.g., tarball entry bytes)
  • ➖ Call sites that parse already-loaded strings/bytes can regress back to raw serde_json usage
2. Use an external Rust BOM-stripping crate for JSON decoding
  • ➕ Avoids custom BOM logic and potential edge cases
  • ➕ Potentially reusable across other file formats
  • ➖ Adds a dependency for a very small behavior (single prefix check)
  • ➖ Still requires enforcing usage across all parse entry points
3. Fold all parsing into `PackageManifest::from_path` (no ad-hoc serde_json usage)
  • ➕ Strongest consistency guarantees for on-disk manifests
  • ➕ Single place to attach path-aware parse diagnostics
  • ➖ Doesn't naturally cover cases that need serde_json::Value without a full PackageManifest (version reads, tarball detection)
  • ➖ Larger refactor and more churn than needed for the fix

Recommendation: The chosen approach (introducing parse_manifest / parse_manifest_bytes and switching callers) is the best tradeoff: it guarantees BOM tolerance across diverse sources (files and tarball bytes) with minimal churn, and it improves error diagnostics by attaching the offending path. The main thing to watch is continued adoption—new manifest parsing should consistently go through these helpers to avoid reintroducing BOM-related failures.

Files changed (13) +201 / -24

Bug fix (7) +53 / -14
build.rsUse BOM-tolerant parsing for deps tree project/version reads +3/-2

Use BOM-tolerant parsing for deps tree project/version reads

• Replaces direct 'serde_json::from_slice' usage with 'parse_manifest_bytes' when reading 'package.json' bytes to derive versions and project summaries.

pnpm/crates/cli/src/cli_args/deps_tree/build.rs

finders.rsParse dependency-tree manifests via parse_manifest_bytes +2/-1

Parse dependency-tree manifests via parse_manifest_bytes

• Routes deps-tree manifest reads through 'parse_manifest_bytes' so BOM-prefixed 'package.json' no longer results in a null manifest.

pnpm/crates/cli/src/cli_args/deps_tree/finders.rs

render.rsMake long package info reading BOM-tolerant +2/-1

Make long package info reading BOM-tolerant

• Switches the optional manifest read for dependency display to 'parse_manifest_bytes', avoiding failures on BOM-prefixed manifests.

pnpm/crates/cli/src/cli_args/deps_tree/render.rs

lib.rsParse global package.json via shared parse_manifest helper +2/-2

Parse global package.json via shared parse_manifest helper

• Replaces 'serde_json::from_str' with 'parse_manifest' for global package manifest reads to accept BOM-prefixed files.

pnpm/crates/global/src/lib.rs

create_virtual_store.rsUse parse_manifest for virtual-store build detection +4/-2

Use parse_manifest for virtual-store build detection

• Updates virtual-store build detection to parse cached 'package.json' contents with BOM stripping via 'parse_manifest'.

pnpm/crates/package-manager/src/create_virtual_store.rs

lib.rsCentralize BOM stripping + add path-aware Parse error +36/-4

Centralize BOM stripping + add path-aware Parse error

• Introduces 'parse_manifest' and 'parse_manifest_bytes' helpers that drop a leading UTF-8 BOM before invoking 'serde_json'. Adds 'PackageManifestError::Parse { path, source }' and migrates core manifest reads (including 'safe_read_package_json_from_dir') to use it so failures report the offending file path.

pnpm/crates/package-manifest/src/lib.rs

lib.rsParse bundled tarball package.json bytes with BOM stripping +4/-2

Parse bundled tarball package.json bytes with BOM stripping

• Switches tarball 'package.json' parsing to 'parse_manifest_bytes' so BOM-prefixed bundled manifests still drive requires-build/install-script detection.

pnpm/crates/tarball/src/lib.rs

Tests (5) +143 / -10
tests.rsUpdate lifecycle error expectation to new Parse variant +2/-5

Update lifecycle error expectation to new Parse variant

• Adjusts the malformed-manifest test to expect the new 'PackageManifestError::Parse' variant rather than 'Serialization'.

pnpm/crates/executor/src/lifecycle/tests.rs

tests.rsAdd BOM regression tests for manifest reads and save behavior +74/-5

Add BOM regression tests for manifest reads and save behavior

• Adds tests ensuring BOM-prefixed manifests parse from disk and bytes, aren’t rewritten on no-op saves, remain errors when BOM appears mid-document, and that path-aware parse errors include the manifest path.

pnpm/crates/package-manifest/src/tests.rs

tests.rsTest BOM-prefixed tarball manifests preserve requires_build detection +30/-0

Test BOM-prefixed tarball manifests preserve requires_build detection

• Adds a tarball extraction test asserting BOM-prefixed bundled 'package.json' is parsed and 'requires_build' is derived correctly.

pnpm/crates/tarball/src/tests.rs

tests.rsPin BOM tolerance for package.yaml project manifests +12/-0

Pin BOM tolerance for package.yaml project manifests

• Adds a regression test ensuring 'package.yaml' with a leading UTF-8 BOM is accepted, matching package.json behavior.

pnpm/crates/workspace/src/project_manifest/tests.rs

tests.rsEnsure workspace discovery handles BOM-prefixed package.json +25/-0

Ensure workspace discovery handles BOM-prefixed package.json

• Adds a workspace discovery test confirming a project with BOM-prefixed 'package.json' is enumerated rather than aborting discovery.

pnpm/crates/workspace/src/projects/tests.rs

Documentation (1) +5 / -0
read-bom-prefixed-manifests.mdAdd changeset for BOM-tolerant manifest parsing +5/-0

Add changeset for BOM-tolerant manifest parsing

• Documents that BOM-prefixed 'package.json' files now parse successfully across read paths, and that malformed manifest errors report the offending path.

.changeset/read-bom-prefixed-manifests.md

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported bin-linking and packed-manifest failures are addressed by routing their reachable readers through the shared BOM-aware parsers, and no blocking failure remains.

Reviews (2): Last reviewed commit: "fix(package-manifest): strip the BOM on ..." | Re-trigger Greptile

Comment thread pnpm/crates/tarball/src/lib.rs Resolved
Comment thread pnpm/crates/package-manifest/src/lib.rs Resolved

@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

🤖 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/cli/src/cli_args/deps_tree/finders.rs`:
- Line 215: Update read_manifest_from_cafs in
pnpm/crates/cli/src/cli_args/deps_tree/finders.rs at lines 215-215 to parse CAFS
manifest bytes through parse_manifest_bytes instead of direct JSON parsing, and
add coverage for BOM-prefixed CAFS manifests. Retain the broad
dependency-manifest claim in .changeset/read-bom-prefixed-manifests.md at lines
5-5 once the CAFS path is covered.

In `@pnpm/crates/executor/src/lifecycle/tests.rs`:
- Around line 449-451: Strengthen the assertion around the
LifecycleScriptError::ReadManifest match in the lifecycle test to validate the
manifest path diagnostic, not just the Parse variant. Destructure the embedded
path and assert it equals pkg_root.join("package.json"), or verify the rendered
error includes that path, while preserving the existing error-variant check.
🪄 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: 13fd8a5f-e3c7-4309-a5af-4fc49dbd3b04

📥 Commits

Reviewing files that changed from the base of the PR and between 875073e and 595856d.

📒 Files selected for processing (13)
  • .changeset/read-bom-prefixed-manifests.md
  • pnpm/crates/cli/src/cli_args/deps_tree/build.rs
  • pnpm/crates/cli/src/cli_args/deps_tree/finders.rs
  • pnpm/crates/cli/src/cli_args/deps_tree/render.rs
  • pnpm/crates/executor/src/lifecycle/tests.rs
  • pnpm/crates/global/src/lib.rs
  • pnpm/crates/package-manager/src/create_virtual_store.rs
  • pnpm/crates/package-manifest/src/lib.rs
  • pnpm/crates/package-manifest/src/tests.rs
  • pnpm/crates/tarball/src/lib.rs
  • pnpm/crates/tarball/src/tests.rs
  • pnpm/crates/workspace/src/project_manifest/tests.rs
  • pnpm/crates/workspace/src/projects/tests.rs

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Manifest dep graph expansion 🐞 Bug ⚙ Maintainability ⭐ New
Description
pacquet-cmd-shim now depends on pacquet-package-manifest just to call parse_manifest_bytes,
which pulls in additional transitive deps (e.g. node-semver, strum, tempfile) and increases
dependency surface/compile cost for a small linking component (similarly for pacquet-publish).
Code

pnpm/crates/cmd-shim/Cargo.toml[R14-15]

+pacquet-fs               = { workspace = true }
+pacquet-package-manifest = { workspace = true }
Relevance

⭐⭐ Medium

Perf/compile-cost concerns sometimes accepted, but similar “avoid extra overhead” refactors are also
rejected; dep split is invasive.

PR-#13309
PR-#13150
PR-#13152

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The focus hunk adds pacquet-package-manifest as a dependency of pacquet-cmd-shim. The
pacquet-package-manifest crate’s own Cargo.toml shows it depends on heavier libraries (including
tempfile, node-semver, strum), and cmd-shim uses it only for parse_manifest_bytes,
indicating the dependency is primarily for this helper API.

pnpm/crates/cmd-shim/Cargo.toml[13-24]
pnpm/crates/package-manifest/Cargo.toml[13-21]
pnpm/crates/cmd-shim/src/link_bins.rs[270-282]
pnpm/crates/publish/Cargo.toml[13-22]

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

### Issue description
`pacquet-cmd-shim` (and `pacquet-publish`) added a dependency on `pacquet-package-manifest` only to access BOM-tolerant JSON parsing helpers. This expands their dependency graph and can increase compile time/binary size and overall dependency surface area.

### Issue Context
- `pacquet-package-manifest` currently brings in dependencies beyond simple JSON parsing (e.g. `node-semver`, `strum`, `tempfile`).
- The call sites in this PR only need BOM-tolerant parsing (`parse_manifest` / `parse_manifest_bytes`).

### Fix Focus Areas
- pnpm/crates/cmd-shim/Cargo.toml[14-15]
- pnpm/crates/publish/Cargo.toml[19-19]

### Suggested fix directions (pick one)
1. **Create a lightweight crate/module** (e.g. `pacquet-json-manifest-parse`) that only depends on `serde_json` and exposes `parse_manifest`/`parse_manifest_bytes`, then depend on that from `cmd-shim`/`publish`.
2. **Feature-split `pacquet-package-manifest`** so crates that only need parsing can disable heavier deps (e.g. make edit/write functionality depend on optional features like `edit`, and keep `parse` minimal).
3. **Inline minimal BOM handling in the small crates** (only where needed) if keeping a shared crate is not feasible right now; document why duplication is acceptable.

Ensure the chosen approach preserves the new BOM-acceptance behavior for all paths added in this PR.

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


2. Ambiguous manifest diagnostic code 🐞 Bug ◔ Observability
Description
PackageManifestError::Parse is tagged with ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR, the
same diagnostic code as PackageManifestError::Serialization, so tooling/users cannot reliably
distinguish parse failures from serialization failures by diagnostic code. This was introduced with
the new Parse variant and will affect all new BOM-tolerant parse paths that now emit `Parse { path,
source }`.
Code

pnpm/crates/package-manifest/src/lib.rs[R21-28]

+    #[from(ignore)] // TODO: remove this after derive(From) has been removed
+    #[display("Failed to parse {}: {source}", path.display())]
+    #[diagnostic(code(ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR))]
+    Parse {
+        path: PathBuf,
+        #[error(source)]
+        source: serde_json::Error,
+    },
Relevance

⭐⭐ Medium

Repo often accepts adding/aligning miette diagnostic codes, but no clear precedent on resolving code
collisions between variants.

PR-#13195
PR-#13101
PR-#13178

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new Parse variant is explicitly annotated with the same
#[diagnostic(code(ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR))] attribute as the existing
Serialization variant, making their diagnostic codes collide.

pnpm/crates/package-manifest/src/lib.rs[15-33]

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

### Issue description
`PackageManifestError::Parse` currently uses the same miette diagnostic `code(...)` as `PackageManifestError::Serialization`, which makes structured diagnostics ambiguous.

### Issue Context
This PR introduces `PackageManifestError::Parse { path, source }` to improve manifest parse errors (including reporting the path). Reusing the serialization code undermines that benefit for consumers that key off the diagnostic code.

### Fix Focus Areas
- pnpm/crates/package-manifest/src/lib.rs[15-33]

### Suggested fix
- Assign `PackageManifestError::Parse` a dedicated diagnostic code (e.g. `ERR_PNPM_PACKAGE_MANIFEST_PARSE_ERROR`) that reflects parsing, while leaving the existing serialization code on the `Serialization` variant.
- If the repo has a central error-code registry/constants, add the new code there.
- (Optional) Add/adjust a test that asserts malformed `package.json` reports the parse-specific diagnostic code, to prevent future regressions.

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



Informational

3. pnpm missing in changeset 📘 Rule violation § Compliance
Description
The new changeset lists only pacquet and omits a pnpm bump entry, which violates the changeset
policy requiring an explicit pnpm package declaration. This can lead to incomplete or incorrect
release/version planning for pnpm.
Code

.changeset/read-bom-prefixed-manifests.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Analogous “add pnpm entry to pacquet-only changeset” compliance suggestions were repeatedly rejected
in recent PRs.

PR-#13304
PR-#13300
PR-#13297

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to contain an entry for the pnpm package
with a valid bump type. The added changeset front-matter includes only "pacquet": patch and does
not declare pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/read-bom-prefixed-manifests.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 an explicit `pnpm` entry, which is required by the compliance checklist.

## Issue Context
This PR introduces a changeset at `.changeset/read-bom-prefixed-manifests.md` that currently declares only `"pacquet": patch`.

## Fix Focus Areas
- .changeset/read-bom-prefixed-manifests.md[1-3]

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


Grey Divider

Previous review results

Review updated until commit ef92260 ⚖️ Balanced

Results up to commit 595856d ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Ambiguous manifest diagnostic code 🐞 Bug ◔ Observability
Description
PackageManifestError::Parse is tagged with ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR, the
same diagnostic code as PackageManifestError::Serialization, so tooling/users cannot reliably
distinguish parse failures from serialization failures by diagnostic code. This was introduced with
the new Parse variant and will affect all new BOM-tolerant parse paths that now emit `Parse { path,
source }`.
Code

pnpm/crates/package-manifest/src/lib.rs[R21-28]

+    #[from(ignore)] // TODO: remove this after derive(From) has been removed
+    #[display("Failed to parse {}: {source}", path.display())]
+    #[diagnostic(code(ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR))]
+    Parse {
+        path: PathBuf,
+        #[error(source)]
+        source: serde_json::Error,
+    },
Relevance

⭐⭐ Medium

Repo often accepts adding/aligning miette diagnostic codes, but no clear precedent on resolving code
collisions between variants.

PR-#13195
PR-#13101
PR-#13178

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new Parse variant is explicitly annotated with the same
#[diagnostic(code(ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR))] attribute as the existing
Serialization variant, making their diagnostic codes collide.

pnpm/crates/package-manifest/src/lib.rs[15-33]

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

### Issue description
`PackageManifestError::Parse` currently uses the same miette diagnostic `code(...)` as `PackageManifestError::Serialization`, which makes structured diagnostics ambiguous.

### Issue Context
This PR introduces `PackageManifestError::Parse { path, source }` to improve manifest parse errors (including reporting the path). Reusing the serialization code undermines that benefit for consumers that key off the diagnostic code.

### Fix Focus Areas
- pnpm/crates/package-manifest/src/lib.rs[15-33]

### Suggested fix
- Assign `PackageManifestError::Parse` a dedicated diagnostic code (e.g. `ERR_PNPM_PACKAGE_MANIFEST_PARSE_ERROR`) that reflects parsing, while leaving the existing serialization code on the `Serialization` variant.
- If the repo has a central error-code registry/constants, add the new code there.
- (Optional) Add/adjust a test that asserts malformed `package.json` reports the parse-specific diagnostic code, to prevent future regressions.

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



Informational
2. pnpm missing in changeset 📘 Rule violation § Compliance
Description
The new changeset lists only pacquet and omits a pnpm bump entry, which violates the changeset
policy requiring an explicit pnpm package declaration. This can lead to incomplete or incorrect
release/version planning for pnpm.
Code

.changeset/read-bom-prefixed-manifests.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Analogous “add pnpm entry to pacquet-only changeset” compliance suggestions were repeatedly rejected
in recent PRs.

PR-#13304
PR-#13300
PR-#13297

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to contain an entry for the pnpm package
with a valid bump type. The added changeset front-matter includes only "pacquet": patch and does
not declare pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/read-bom-prefixed-manifests.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 an explicit `pnpm` entry, which is required by the compliance checklist.

## Issue Context
This PR introduces a changeset at `.changeset/read-bom-prefixed-manifests.md` that currently declares only `"pacquet": patch`.

## Fix Focus Areas
- .changeset/read-bom-prefixed-manifests.md[1-3]

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


Qodo Logo

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.6±0.02ms    32.2 MB/sec    1.02     11.8±0.05ms    31.7 MB/sec
packument/parse                1.00     37.9±0.09µs  1751.4 MB/sec    1.09     41.3±0.20µs  1605.9 MB/sec
tarball/download_dependency    1.00      2.2±0.08ms  1946.6 KB/sec    1.01      2.2±0.06ms  1928.3 KB/sec

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.80488% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.03%. Comparing base (875073e) to head (ef92260).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/pack_app.rs 25.00% 3 Missing ⚠️
pnpm/crates/cli/src/cli_args/deps_tree/finders.rs 50.00% 1 Missing ⚠️
...rates/cli/src/cli_args/self_update/install_pnpm.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13327      +/-   ##
==========================================
- Coverage   87.05%   87.03%   -0.02%     
==========================================
  Files         532      533       +1     
  Lines       91601    91692      +91     
==========================================
+ Hits        79741    79805      +64     
- Misses      11860    11887      +27     

☔ 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

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 595856df544c

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

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.504 ± 0.150 2.347 2.752 1.74 ± 0.18
pacquet@main 2.507 ± 0.151 2.360 2.721 1.74 ± 0.19
pnpr@HEAD 1.440 ± 0.097 1.339 1.653 1.00 ± 0.11
pnpr@main 1.440 ± 0.127 1.340 1.723 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5035484295800003,
      "stddev": 0.15015097875641273,
      "median": 2.47984798418,
      "user": 1.70353146,
      "system": 1.3230420199999997,
      "min": 2.34725424268,
      "max": 2.75207237568,
      "times": [
        2.35907479068,
        2.49126597468,
        2.75207237568,
        2.38819883868,
        2.46842999368,
        2.64678415768,
        2.54232597968,
        2.69119599168,
        2.34888195068,
        2.34725424268
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5073663072800003,
      "stddev": 0.15074987438623988,
      "median": 2.44570748518,
      "user": 1.6811112600000002,
      "system": 1.3490560200000001,
      "min": 2.35965638868,
      "max": 2.72117497168,
      "times": [
        2.42403131068,
        2.36968557068,
        2.41062757968,
        2.46738365968,
        2.71815873568,
        2.70135065968,
        2.72117497168,
        2.37438987168,
        2.52720432468,
        2.35965638868
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.44015764168,
      "stddev": 0.0966367793129502,
      "median": 1.43561527468,
      "user": 1.18337776,
      "system": 1.1751221199999997,
      "min": 1.33870419868,
      "max": 1.6525997436800002,
      "times": [
        1.3592112086800001,
        1.6525997436800002,
        1.42830429568,
        1.45313505768,
        1.37065408768,
        1.34834560468,
        1.51765988968,
        1.49003607668,
        1.33870419868,
        1.44292625368
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.4398298081799998,
      "stddev": 0.12651165330613393,
      "median": 1.39258715018,
      "user": 1.1945393599999998,
      "system": 1.1570606199999998,
      "min": 1.34033936568,
      "max": 1.72327552568,
      "times": [
        1.72327552568,
        1.51630009968,
        1.40759718768,
        1.37954502268,
        1.3578301696800001,
        1.3516586026800002,
        1.34197201268,
        1.57415081768,
        1.4056292776800001,
        1.34033936568
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 252.9 ± 5.5 241.0 261.3 1.00
pacquet@main 253.5 ± 5.5 248.5 265.9 1.00 ± 0.03
pnpr@HEAD 267.2 ± 10.3 254.6 284.0 1.06 ± 0.05
pnpr@main 268.2 ± 7.3 254.4 278.6 1.06 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25288565326,
      "stddev": 0.00546842073294813,
      "median": 0.25276358916,
      "user": 0.20290555999999998,
      "system": 0.5079132599999999,
      "min": 0.24103873066,
      "max": 0.26129443266,
      "times": [
        0.25187524666,
        0.25084764166,
        0.25245953766,
        0.25337523166000003,
        0.24103873066,
        0.25444206466,
        0.25080923266,
        0.25964677366,
        0.26129443266,
        0.25306764066000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25348965616,
      "stddev": 0.005465256536136277,
      "median": 0.25269288066,
      "user": 0.19868495999999997,
      "system": 0.51975386,
      "min": 0.24847240766000003,
      "max": 0.26592625466,
      "times": [
        0.24882078266000002,
        0.25534813166000003,
        0.24949140666000003,
        0.24847240766000003,
        0.25479969866,
        0.25058606266,
        0.25534721766,
        0.25716088966,
        0.24894370966,
        0.26592625466
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26720757596,
      "stddev": 0.010285401733955559,
      "median": 0.26504653866000005,
      "user": 0.20669195999999998,
      "system": 0.5167555599999999,
      "min": 0.25456717166000004,
      "max": 0.28396831666,
      "times": [
        0.28241842566,
        0.25964486466000003,
        0.27181914066,
        0.27296459966000003,
        0.26542602166,
        0.26466705566000004,
        0.25853847166000005,
        0.25456717166000004,
        0.25806169166000004,
        0.28396831666
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.2681556714600001,
      "stddev": 0.0072513805715520374,
      "median": 0.26891326216,
      "user": 0.21971725999999997,
      "system": 0.50901636,
      "min": 0.25442001066000003,
      "max": 0.27855408066000004,
      "times": [
        0.27521214866000004,
        0.27039258466000005,
        0.26689864766000004,
        0.26137112766000004,
        0.27433726166,
        0.25442001066000003,
        0.27017668666,
        0.26254432866000005,
        0.26764983766,
        0.27855408066000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.763 ± 0.013 2.742 2.790 1.74 ± 0.18
pacquet@main 2.739 ± 0.010 2.719 2.752 1.73 ± 0.18
pnpr@HEAD 1.584 ± 0.163 1.446 1.883 1.00
pnpr@main 1.629 ± 0.131 1.451 1.852 1.03 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7629781425000006,
      "stddev": 0.01284309145985408,
      "median": 2.7601796092000006,
      "user": 1.8915793,
      "system": 1.31190962,
      "min": 2.7416182097000004,
      "max": 2.7895871677,
      "times": [
        2.7599839117000005,
        2.7603753067000003,
        2.7416182097000004,
        2.7667070967000003,
        2.7651220547000004,
        2.7559771287,
        2.7895871677,
        2.7581699437,
        2.7562689807000003,
        2.7759716247000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7389212956,
      "stddev": 0.010196414472019093,
      "median": 2.7402071122000002,
      "user": 1.8391319,
      "system": 1.3415954199999998,
      "min": 2.7194403277,
      "max": 2.7517667767000002,
      "times": [
        2.7273820217,
        2.7517662987000002,
        2.7517667767000002,
        2.7361106377000004,
        2.7402975937000003,
        2.7421715257000003,
        2.7401166307,
        2.7194403277,
        2.7459356427,
        2.7342255007000005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5840130399999999,
      "stddev": 0.1632030939098107,
      "median": 1.5186407417,
      "user": 1.1935194,
      "system": 1.1826873199999999,
      "min": 1.4461993337,
      "max": 1.8826712417,
      "times": [
        1.4470033947,
        1.5100955587,
        1.8826712417,
        1.5437216637,
        1.5153570757000001,
        1.5219244077,
        1.8595936407,
        1.6559604567000001,
        1.4461993337,
        1.4576036266999999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6291076196999998,
      "stddev": 0.13084264529953513,
      "median": 1.6213222847,
      "user": 1.1894917000000003,
      "system": 1.1920469199999997,
      "min": 1.4512765627,
      "max": 1.8517298007,
      "times": [
        1.4512765627,
        1.4840321957,
        1.6197332057,
        1.5310799767,
        1.7990530757,
        1.6231283287,
        1.6229113636999999,
        1.7313576727,
        1.5767740147,
        1.8517298007
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 583.6 ± 16.0 561.6 613.9 1.94 ± 0.08
pacquet@main 563.4 ± 9.8 551.9 582.7 1.87 ± 0.06
pnpr@HEAD 301.7 ± 9.4 288.2 318.4 1.00 ± 0.04
pnpr@main 300.8 ± 8.4 285.1 311.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5835764688400001,
      "stddev": 0.01603402258802754,
      "median": 0.5788161167400001,
      "user": 0.6872912999999998,
      "system": 0.6891307799999999,
      "min": 0.5616186287400001,
      "max": 0.6138971727400001,
      "times": [
        0.5736657397400001,
        0.5822163007400001,
        0.57541593274,
        0.5746659137400001,
        0.5748104457400001,
        0.6138971727400001,
        0.6071437407400001,
        0.5893737927400001,
        0.5829570207400001,
        0.5616186287400001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.56339033354,
      "stddev": 0.009829765672330744,
      "median": 0.5606637157400001,
      "user": 0.6995099999999999,
      "system": 0.66294958,
      "min": 0.55189365674,
      "max": 0.58270691774,
      "times": [
        0.5593702667400001,
        0.55668960574,
        0.58270691774,
        0.55189365674,
        0.5640596157400001,
        0.5741862587400001,
        0.5714936747400001,
        0.56195716474,
        0.55688910974,
        0.5546570647400001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30172493464,
      "stddev": 0.00936455359033775,
      "median": 0.29768627074,
      "user": 0.1850186,
      "system": 0.52098768,
      "min": 0.28816567674,
      "max": 0.31841831074,
      "times": [
        0.30822703274,
        0.28816567674,
        0.29775945774,
        0.29513365974,
        0.29526283574,
        0.30616033674,
        0.31306569074,
        0.29761308374,
        0.31841831074,
        0.29744326174
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30081030884000004,
      "stddev": 0.008436015761022176,
      "median": 0.30086600374,
      "user": 0.2005556,
      "system": 0.49041988,
      "min": 0.28511898774,
      "max": 0.31138548374,
      "times": [
        0.30582118974,
        0.29490970874,
        0.29842163374,
        0.31138548374,
        0.30828658174,
        0.29261173474,
        0.28511898774,
        0.30331037373999997,
        0.29839326574,
        0.30984412874
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.906 ± 0.007 1.899 1.918 6.43 ± 0.17
pacquet@main 1.897 ± 0.011 1.887 1.918 6.40 ± 0.17
pnpr@HEAD 0.297 ± 0.007 0.286 0.308 1.00 ± 0.03
pnpr@main 0.296 ± 0.008 0.289 0.316 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9058553091800001,
      "stddev": 0.007027879316018927,
      "median": 1.90347815368,
      "user": 0.9494090199999997,
      "system": 0.7635936799999999,
      "min": 1.89855016568,
      "max": 1.91801417068,
      "times": [
        1.9055394166800002,
        1.9078617416800001,
        1.91801417068,
        1.89855016568,
        1.90031657468,
        1.9123742696800001,
        1.90103600768,
        1.90141689068,
        1.91451902568,
        1.89892482868
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.89676050258,
      "stddev": 0.010655992352445019,
      "median": 1.89376768918,
      "user": 0.9581605199999998,
      "system": 0.7537450800000001,
      "min": 1.88673605768,
      "max": 1.91806384868,
      "times": [
        1.91806384868,
        1.88850011268,
        1.89773943068,
        1.88697026568,
        1.90237462868,
        1.88673605768,
        1.9096711826800001,
        1.88979594768,
        1.89830664968,
        1.8894469016800002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29680207508000006,
      "stddev": 0.006799946132908829,
      "median": 0.29737455418000003,
      "user": 0.18742102,
      "system": 0.5164981799999999,
      "min": 0.28618903768000004,
      "max": 0.30808847068,
      "times": [
        0.29773355668,
        0.29232667268,
        0.29930096368000003,
        0.29776542668,
        0.29293125168,
        0.28618903768000004,
        0.29701555168000005,
        0.30634542568,
        0.30808847068,
        0.29032439368
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29638369818,
      "stddev": 0.0076270250465781545,
      "median": 0.29475529418,
      "user": 0.18752892,
      "system": 0.50384508,
      "min": 0.28860722468,
      "max": 0.31635037368,
      "times": [
        0.29509195368,
        0.29306231068000005,
        0.29306198368,
        0.29085262968000003,
        0.29750701368000004,
        0.29627836868,
        0.29441863468,
        0.31635037368,
        0.29860648868,
        0.28860722468
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 364.9 ± 7.0 354.6 374.0 4.12 ± 0.16
pacquet@main 358.8 ± 8.3 349.1 372.3 4.05 ± 0.17
pnpr@HEAD 89.0 ± 2.8 84.7 95.2 1.00 ± 0.05
pnpr@main 88.7 ± 3.0 85.5 97.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.36494966094000003,
      "stddev": 0.0070037406658207775,
      "median": 0.36573135623999997,
      "user": 0.35239447999999995,
      "system": 0.07570683999999998,
      "min": 0.35457025974,
      "max": 0.37397821374,
      "times": [
        0.35834407874,
        0.36048806574000003,
        0.35457025974,
        0.35703939074,
        0.36911207974,
        0.37164294874000003,
        0.36605496074,
        0.37397821374,
        0.36540775174,
        0.37285885974
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.35881452334,
      "stddev": 0.008303309939693557,
      "median": 0.35545939074,
      "user": 0.34956018,
      "system": 0.06922383999999998,
      "min": 0.34907257074000003,
      "max": 0.37229208374,
      "times": [
        0.36523168374000003,
        0.34959100674,
        0.35309990774,
        0.36816870374,
        0.35655620474,
        0.35395520274000003,
        0.35436257674,
        0.34907257074000003,
        0.36581529274,
        0.37229208374
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.0890118651036364,
      "stddev": 0.0028120683029372357,
      "median": 0.08885974774000001,
      "user": 0.0193120496969697,
      "system": 0.012920558181818179,
      "min": 0.08473401974000001,
      "max": 0.09518933374,
      "times": [
        0.08507014774,
        0.08659964674000001,
        0.09063118274000001,
        0.09491131874000001,
        0.08896226074000001,
        0.08617165574,
        0.09218017974,
        0.08862259074,
        0.09021521974,
        0.08676522674,
        0.08473401974000001,
        0.09450905774000001,
        0.08885974774000001,
        0.09275896174,
        0.08864339974000002,
        0.08957275274000001,
        0.08756611074000001,
        0.09114787374000001,
        0.09518933374,
        0.08658073874000001,
        0.09070578474000002,
        0.09194614974000001,
        0.08627684774000001,
        0.08553786874000001,
        0.08773416474000001,
        0.08930543074000001,
        0.08921677874000002,
        0.09018670474000001,
        0.08594251574000002,
        0.08696050574000001,
        0.08697170374000002,
        0.08971862374000002,
        0.08719704374000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08866090264322583,
      "stddev": 0.0030033561612893937,
      "median": 0.08740506074000001,
      "user": 0.02229991870967742,
      "system": 0.00936682129032258,
      "min": 0.08551301474,
      "max": 0.09781695674000002,
      "times": [
        0.08905130274,
        0.08645612174000002,
        0.09399410074000002,
        0.09007423574000001,
        0.08556073274,
        0.09222565974000001,
        0.08553547474,
        0.08694839574000002,
        0.08867144674,
        0.08860462174000001,
        0.08651894774,
        0.08740506074000001,
        0.08643908474,
        0.08724655174000001,
        0.08592501874000001,
        0.08712274774,
        0.09028095474000002,
        0.08731204874000001,
        0.08577677674,
        0.08579951074000002,
        0.09251491474000001,
        0.08551301474,
        0.09122059674,
        0.08599838774000002,
        0.08887763074,
        0.09347945574000001,
        0.08933644374000001,
        0.08822223974000001,
        0.08712248074000001,
        0.09781695674000002,
        0.09143706574000002
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.492 ± 0.102 4.416 4.761 1.28 ± 0.05
pacquet@main 4.506 ± 0.075 4.430 4.668 1.28 ± 0.05
pnpr@HEAD 3.547 ± 0.151 3.444 3.840 1.01 ± 0.05
pnpr@main 3.522 ± 0.120 3.439 3.813 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.4916706956,
      "stddev": 0.10195813452799769,
      "median": 4.457564918999999,
      "user": 1.8445568599999997,
      "system": 1.4386991999999998,
      "min": 4.4161665725,
      "max": 4.7608758325,
      "times": [
        4.554819084499999,
        4.4381038015,
        4.4161665725,
        4.4713272024999995,
        4.7608758325,
        4.4347961645,
        4.460803277499999,
        4.454326560499999,
        4.442004069499999,
        4.483484390499999
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5055206477,
      "stddev": 0.07493391368548956,
      "median": 4.4812781379999995,
      "user": 1.82572896,
      "system": 1.4547022,
      "min": 4.4299832125,
      "max": 4.6682780015,
      "times": [
        4.5545184784999995,
        4.454680993499999,
        4.4513585245,
        4.5148052535,
        4.6682780015,
        4.502178843499999,
        4.4299832125,
        4.4452718695,
        4.4603774325,
        4.5737538675
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5465621219,
      "stddev": 0.15053590646693385,
      "median": 3.4850184855,
      "user": 1.28389756,
      "system": 1.2701703,
      "min": 3.4442750395,
      "max": 3.8397493995,
      "times": [
        3.5011853935,
        3.4779800255,
        3.8397493995,
        3.4442750395,
        3.5059802505,
        3.4683647755,
        3.4548432155,
        3.8193904915,
        3.4920569455,
        3.4617956825
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.5219095366,
      "stddev": 0.1197405552317194,
      "median": 3.4642938315,
      "user": 1.2963239599999998,
      "system": 1.2368777,
      "min": 3.4386062225000003,
      "max": 3.8126658375,
      "times": [
        3.4643150305,
        3.4386062225000003,
        3.4545818725,
        3.5209002185,
        3.5186629105000002,
        3.4500329515,
        3.4477819615,
        3.8126658375,
        3.4642726325,
        3.6472757285
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13327
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
2,741.62 ms
(-2.95%)Baseline: 2,825.03 ms
3,390.03 ms
(80.87%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,898.55 ms
(-5.05%)Baseline: 1,999.49 ms
2,399.38 ms
(79.13%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
561.62 ms
(-15.70%)Baseline: 666.24 ms
799.48 ms
(70.25%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
354.57 ms
(-13.16%)Baseline: 408.32 ms
489.98 ms
(72.36%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,347.25 ms
(-2.84%)Baseline: 2,415.93 ms
2,899.11 ms
(80.96%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,416.17 ms
(-2.24%)Baseline: 4,517.18 ms
5,420.62 ms
(81.47%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
241.04 ms
(-12.14%)Baseline: 274.34 ms
329.20 ms
(73.22%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13327
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,446.20 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
286.19 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
288.17 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.73 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,338.70 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,444.28 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
254.57 ms
🐰 View full continuous benchmarking report in Bencher

Extraction accepting a BOM-prefixed package.json is not enough on its own:
bin linking, dependency pruning, the CAFS manifest lookup behind `pnpm list`,
`pnpm publish <tarball>`, and the archive-subdirectory manifest read all
deserialized the same bytes with serde_json directly, so a package Vite-style
manifest would still fail the install after extraction had accepted it.

Route them through parse_manifest / parse_manifest_bytes as well, along with
the manifest reads behind `packageManager` detection, dlx, pack --app, stage,
self-update and `pnpm with`. pacquet-cmd-shim and pacquet-publish gain a
dependency on pacquet-package-manifest for the shared helpers.

The lifecycle-script test now asserts the reported path, not just the error
variant, since reporting the path is what the variant exists for.
Copilot AI review requested due to automatic review settings July 25, 2026 12:02

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Follow-up in ef92260 addresses the review findings; two Qodo points I am not acting on, with reasons.

Acted on — the P1s were right, and they pointed at a real hole: extraction accepting a BOM-prefixed manifest was not enough, because bin linking re-parsed the same bytes and would have failed the install anyway. Every remaining package.json parse now goes through parse_manifest / parse_manifest_bytes: bin linking (pacquet-cmd-shim, pacquet-package-manager::link_bins), prune_direct_deps, the CAFS manifest lookup behind pnpm list, pnpm publish <tarball>, read_subdir_manifest in pacquet-tarball, and the packageManager / dlx / pack --app / stage / self-update / pnpm with reads. New tests cover bin linking and packed-manifest extraction, and the lifecycle test now asserts the reported path rather than only the error variant.

Not acted on — dedicated diagnostic code for Parse. ERR_PNPM_PACKAGE_MANIFEST_SERIALIZATION_ERROR is what a malformed package.json reports today, and error codes are part of the public contract rather than an implementation detail. Giving the new variant its own code would change the code users and tooling see for an unchanged failure — a user-visible change that also deserves a look at the TypeScript side, which reports ERR_PNPM_JSON_PARSE / ERR_PNPM_BAD_PACKAGE_JSON here. That alignment is worth doing deliberately, not as a side effect of a BOM fix. This PR only adds the path to the message.

Not acted on — pnpm missing from the changeset. Deliberate. pnpm in a changeset means the TypeScript CLI package, and per AGENTS.md a Rust-only change targets pacquet and must omit it. The TypeScript CLI already strips the BOM, so nothing ships there.


Written by an agent (Claude Code, claude-opus-5[1m]).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ef92260

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@zkochan
zkochan merged commit e2b4556 into main Jul 25, 2026
36 of 37 checks passed
@zkochan
zkochan deleted the fix/bom-package-json branch July 25, 2026 12:07
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…8 BOM (pnpm#13327)

serde_json rejects a leading byte order mark, so a manifest carrying one
failed the whole read with "expected value at line 1 column 1". Workspace
discovery aborted on it, which made pnpm 12 unusable in repositories that
keep such a manifest on purpose — vitejs/vite ships
playground/resolve/utf8-bom-package/package.json and matches it with its
workspace patterns.

Route every manifest parse through parse_manifest / parse_manifest_bytes,
which drop the BOM first. pnpm decodes manifests through strip-bom and
TextDecoder, so both stacks now accept the same files: project manifests,
dependency manifests read from node_modules, and the package.json bundled
in a tarball. The BOM only disappears from a file once a real change makes
the writer emit the manifest afresh.

A manifest that really is malformed now reports its path, which the
workspace-discovery diagnostic previously omitted.

Closes pnpm#13311
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 12 rejects BOM-prefixed package.json files during workspace discovery

3 participants