Skip to content

fix(cli): match pnpm's JSON error output for publish --json failures - #13029

Merged
zkochan merged 7 commits into
pnpm:mainfrom
Andarist:fix/json-errors-rust
Jul 15, 2026
Merged

zkochan merged 7 commits into
pnpm:mainfrom
Andarist:fix/json-errors-rust

Conversation

@Andarist

@Andarist Andarist commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

I found this issue while trying to test pnpm 12 with Changesets.

Squash Commit Body

Made pacquet's `--json` error reporting print to `stdout` in the raw form (without human-readable formatting). This allows the output to be machine-processed.

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.
  • Updated the documentation if needed.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • Added structured JSON error output for pacquet publish --json, including a JSON error envelope and exit code 1.
    • In JSON mode, diagnostic/reporters are suppressed (including when --reporter=ndjson is set).
    • OTP non-interactive authentication errors now include authUrl/doneUrl in the JSON error payload when available.
  • Bug Fixes
    • Prevented sensitive nested error details from appearing in the user-facing JSON error message.
  • Tests
    • Added integration and unit tests to verify JSON success/failure output and message sanitization.

@Andarist
Andarist requested a review from zkochan as a code owner July 15, 2026 10:52
@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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: bf5f16f7-61fb-43c9-8972-6f28b8524aeb

📥 Commits

Reviewing files that changed from the base of the PR and between fecba0e and e2566f5.

📒 Files selected for processing (7)
  • .changeset/pacquet-publish-json-errors.md
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/dispatch/tests.rs
  • pnpm/crates/cli/src/cli_args/dispatch_query.rs
  • pnpm/crates/cli/src/cli_args/pack.rs
  • pnpm/crates/cli/src/cli_args/publish.rs
  • pnpm/crates/cli/tests/publish.rs
🚧 Files skipped from review as they are similar to previous changes (5)
  • .changeset/pacquet-publish-json-errors.md
  • pnpm/crates/cli/src/cli_args/dispatch/tests.rs
  • pnpm/crates/cli/src/cli_args/dispatch_query.rs
  • pnpm/crates/cli/tests/publish.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs

📝 Walkthrough

Walkthrough

pacquet publish --json now uses silent reporting, emits structured failures as JSON on stdout, preserves OTP authentication URLs, and suppresses human-readable stderr diagnostics. Unit and integration tests cover success and failure behavior.

Changes

Publish JSON output

Layer / File(s) Summary
JSON error dispatch and shared pack context
pnpm/crates/cli/src/cli_args/dispatch.rs, pnpm/crates/cli/src/cli_args/dispatch/tests.rs, pnpm/crates/cli/src/cli_args/pack.rs, pnpm/crates/cli/src/cli_args/publish.rs
Publish JSON mode handles routing and async errors by printing JSON envelopes with codes, condensed messages, and optional OTP URLs. Pack and publish reuse a shared error context, with unit tests covering message extraction.
Publish JSON wiring and validation
pnpm/crates/cli/src/cli_args/dispatch_query.rs, pnpm/crates/cli/tests/publish.rs, .changeset/pacquet-publish-json-errors.md
JSON publish uses SilentReporter, and integration tests plus the changeset cover reporter suppression, stdout failures, and preserved OTP URLs.

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

Possibly related PRs

  • pnpm/pnpm#12691: Adds the publish command/query wiring that this JSON-specific dispatch builds on.

Suggested labels: product: pacquet

Suggested reviewers: zkochan, ksxgithub

Sequence Diagram(s)

sequenceDiagram
  participant CliArgsRun
  participant PublishDispatch
  participant SilentReporter
  participant JsonErrorEnvelope
  CliArgsRun->>PublishDispatch: route publish command
  PublishDispatch->>SilentReporter: run JSON publish flow
  PublishDispatch-->>CliArgsRun: return publish error
  CliArgsRun->>JsonErrorEnvelope: serialize error details
  JsonErrorEnvelope-->>CliArgsRun: write envelope to stdout
Loading
✨ 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: 3

🤖 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 @.changeset/pacquet-publish-json-errors.md:
- Around line 1-5: Combine the publish JSON contract changes into
.changeset/pacquet-publish-json-errors.md by retaining its entry and adding that
the human diagnostic is suppressed for this path; remove the duplicate entry
from .changeset/pacquet-publish-json-reporter.md.

In `@pnpm/crates/cli/src/cli_args/dispatch.rs`:
- Around line 422-434: Update json_error_message to return only the canonical
pnpm diagnostic message instead of joining the complete error chain, while
preserving the existing special handling for “pack the package” and explicitly
whitelisting any intended supplemental fields. Add a regression test with a
sensitive nested cause and verify the JSON error envelope omits that cause and
any secret data.
- Around line 416-419: Update the JSON output serialization in the dispatch path
to use serde_json::to_string instead of serde_json::to_string_pretty, preserving
compact machine-readable stdout and pnpm output parity. Keep the existing
serialization assertion behavior and println! flow unchanged.
🪄 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: c513f0fd-af11-4c36-b00e-697381f8609a

📥 Commits

Reviewing files that changed from the base of the PR and between d5b4b7b and 6d5bf84.

📒 Files selected for processing (5)
  • .changeset/pacquet-publish-json-errors.md
  • .changeset/pacquet-publish-json-reporter.md
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/dispatch_query.rs
  • pnpm/crates/cli/tests/publish.rs

@greptile-apps

greptile-apps Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge. The change is well-scoped to the publish JSON error path and does not affect non-JSON invocations.

The config and state closures are lazy (only called inside the future), so all publish errors — including config-load failures — fall through the new match route(...) intercept and are correctly JSON-formatted. The PACK_ERROR_CONTEXT const eliminates the fragile string duplication flagged in the prior review. Integration tests cover the success case, the error case, the OTP URL case, and the --reporter suppression case.

No files require special attention.

Reviews (4): Last reviewed commit: "fix(cli): keep publish --json error enve..." | Re-trigger Greptile

@codecov-commenter

codecov-commenter commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.54545% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.54%. Comparing base (b49c224) to head (e2566f5).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/dispatch.rs 94.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13029   +/-   ##
=======================================
  Coverage   85.53%   85.54%           
=======================================
  Files         498      498           
  Lines       79541    79595   +54     
=======================================
+ Hits        68037    68087   +50     
- Misses      11504    11508    +4     

☔ 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: 379d8b91bf08

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.624 ± 0.098 2.472 2.785 1.76 ± 0.16
pacquet@main 2.774 ± 0.184 2.490 3.010 1.86 ± 0.20
pnpr@HEAD 1.577 ± 0.156 1.343 1.798 1.06 ± 0.14
pnpr@main 1.492 ± 0.126 1.359 1.697 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6242684952199995,
      "stddev": 0.09761149277419168,
      "median": 2.62998716412,
      "user": 1.9047067599999998,
      "system": 1.5456233000000001,
      "min": 2.47197731162,
      "max": 2.78484793962,
      "times": [
        2.78484793962,
        2.69356744362,
        2.5694885096199997,
        2.72735857662,
        2.53629970562,
        2.5335464066199997,
        2.64728114162,
        2.61269318662,
        2.66562473062,
        2.47197731162
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.77394995992,
      "stddev": 0.18371075056807593,
      "median": 2.78873903662,
      "user": 2.20261576,
      "system": 1.7797177000000002,
      "min": 2.49030338762,
      "max": 3.00988498362,
      "times": [
        2.97062453462,
        2.87534398962,
        2.60440474462,
        2.70213408362,
        2.57524230462,
        2.87610542662,
        3.00988498362,
        2.49030338762,
        2.94224270962,
        2.69321343462
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5770756491199998,
      "stddev": 0.15615976702439557,
      "median": 1.62760269712,
      "user": 1.1362062600000002,
      "system": 1.2597203000000001,
      "min": 1.34329839662,
      "max": 1.79811694362,
      "times": [
        1.6603829616199999,
        1.34329839662,
        1.69478095962,
        1.79811694362,
        1.37968898662,
        1.61347147162,
        1.39573382662,
        1.53864968462,
        1.7048993376200001,
        1.6417339226199998
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.4918564027199999,
      "stddev": 0.12552058824200696,
      "median": 1.47234621962,
      "user": 1.17910566,
      "system": 1.2478563999999999,
      "min": 1.35891267262,
      "max": 1.69734668462,
      "times": [
        1.3724530826199999,
        1.37568141962,
        1.4050720616199999,
        1.57637684062,
        1.57347329762,
        1.53962037762,
        1.35891267262,
        1.38758079062,
        1.6320467996199999,
        1.69734668462
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 292.8 ± 60.2 218.9 387.8 1.09 ± 0.26
pacquet@main 304.4 ± 45.0 260.1 406.1 1.13 ± 0.22
pnpr@HEAD 275.5 ± 16.4 256.0 301.1 1.02 ± 0.14
pnpr@main 269.3 ± 34.5 213.0 322.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29282566676000005,
      "stddev": 0.0602333788196659,
      "median": 0.26609061236,
      "user": 0.28141126,
      "system": 0.74152194,
      "min": 0.21887119386,
      "max": 0.38784084286000003,
      "times": [
        0.21887119386,
        0.24971043086,
        0.26288787686000004,
        0.27304674086,
        0.26607485386,
        0.35691844786000004,
        0.38784084286000003,
        0.38505222686,
        0.26174768286,
        0.26610637086
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.30439479446,
      "stddev": 0.045046323885515785,
      "median": 0.30110643486,
      "user": 0.30425456,
      "system": 0.77524644,
      "min": 0.26013448186,
      "max": 0.40610787086,
      "times": [
        0.26276629286000003,
        0.27386159486,
        0.29833834786,
        0.30387452186,
        0.33842791386000004,
        0.32164514986000003,
        0.40610787086,
        0.31537755486,
        0.26341421586,
        0.26013448186
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27552464436000007,
      "stddev": 0.01636905996529539,
      "median": 0.27484387986000003,
      "user": 0.24700076,
      "system": 0.6748411399999998,
      "min": 0.25595527886,
      "max": 0.30113561986000004,
      "times": [
        0.28370490386,
        0.28598881686,
        0.29527121486,
        0.26598285586000003,
        0.30113561986000004,
        0.25595527886,
        0.26118491686,
        0.25925898886,
        0.28424154686,
        0.26252230086
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.26932633846,
      "stddev": 0.0344907367028622,
      "median": 0.25545286636000003,
      "user": 0.24732165999999997,
      "system": 0.65500194,
      "min": 0.21295752286,
      "max": 0.32218199386,
      "times": [
        0.21295752286,
        0.24535070486000002,
        0.25537099686000003,
        0.31838328086,
        0.25553473586000003,
        0.27316537986,
        0.25524384686,
        0.30013237486,
        0.32218199386,
        0.25494254786000003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.124 ± 0.157 2.908 3.436 2.08 ± 0.18
pacquet@main 3.074 ± 0.108 2.917 3.273 2.05 ± 0.16
pnpr@HEAD 1.571 ± 0.191 1.405 1.878 1.05 ± 0.15
pnpr@main 1.499 ± 0.102 1.387 1.667 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.1242632767200003,
      "stddev": 0.1570310429630485,
      "median": 3.1341953498199997,
      "user": 2.5915868599999996,
      "system": 1.8742421599999997,
      "min": 2.90755538232,
      "max": 3.4363595183199998,
      "times": [
        2.94265234032,
        3.4363595183199998,
        3.01043063432,
        3.22831315932,
        3.08559430532,
        2.90755538232,
        3.18472691932,
        3.18279639432,
        3.0543350343199998,
        3.2098690793199998
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.07411188812,
      "stddev": 0.10847902861215943,
      "median": 3.07595278832,
      "user": 2.42433286,
      "system": 1.7747963599999999,
      "min": 2.91658529532,
      "max": 3.27263985632,
      "times": [
        3.11060825332,
        3.18504443832,
        3.04129732332,
        2.99069984532,
        3.12518834532,
        2.91658529532,
        2.99337588832,
        3.27263985632,
        2.9822111153199997,
        3.12346852032
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5707247151200001,
      "stddev": 0.1910912067379358,
      "median": 1.48002715532,
      "user": 1.21753106,
      "system": 1.35103676,
      "min": 1.40539604132,
      "max": 1.87789582532,
      "times": [
        1.46865201032,
        1.82954339232,
        1.87789582532,
        1.4914023003199999,
        1.8224701313199998,
        1.50743751732,
        1.4176855763199998,
        1.4400097353199999,
        1.44675462132,
        1.40539604132
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.4989295463199999,
      "stddev": 0.10223226645859333,
      "median": 1.48542887232,
      "user": 1.04347856,
      "system": 1.1933129599999999,
      "min": 1.38714582332,
      "max": 1.6670669943199998,
      "times": [
        1.41894956232,
        1.62566733932,
        1.6670669943199998,
        1.38714582332,
        1.3950282673199998,
        1.57095581632,
        1.39933011832,
        1.55429379732,
        1.51285893332,
        1.45799881132
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 666.9 ± 122.0 569.3 865.7 2.45 ± 0.46
pacquet@main 629.1 ± 64.2 542.2 725.7 2.31 ± 0.26
pnpr@HEAD 271.9 ± 11.7 257.0 293.1 1.00
pnpr@main 288.9 ± 23.8 257.5 337.8 1.06 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.66686864148,
      "stddev": 0.1219719497010616,
      "median": 0.58574266048,
      "user": 0.8056701000000001,
      "system": 0.75199648,
      "min": 0.56926504848,
      "max": 0.8657402254800001,
      "times": [
        0.57452949848,
        0.58131310648,
        0.56926504848,
        0.57140750348,
        0.57247714348,
        0.76840688948,
        0.8404249064800001,
        0.8657402254800001,
        0.73494987848,
        0.59017221448
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6291132349799999,
      "stddev": 0.06417956476935978,
      "median": 0.6199561784800001,
      "user": 0.7740395999999999,
      "system": 0.69122778,
      "min": 0.5421971304800001,
      "max": 0.7256780524800001,
      "times": [
        0.5421971304800001,
        0.55873575748,
        0.5899752114800001,
        0.58095898848,
        0.63729041748,
        0.6560947424800001,
        0.7256780524800001,
        0.68925080348,
        0.6026219394800001,
        0.70832930648
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2718782679800001,
      "stddev": 0.011714041229554457,
      "median": 0.27363051798000004,
      "user": 0.22267349999999997,
      "system": 0.52641978,
      "min": 0.25702006648000003,
      "max": 0.29308927948,
      "times": [
        0.27780841648000004,
        0.27244748448000006,
        0.27985848748000003,
        0.28107526448000003,
        0.27481355148000003,
        0.25835099848000004,
        0.25702006648000003,
        0.26204313048000005,
        0.29308927948,
        0.26227600048000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28888999418000005,
      "stddev": 0.023773283506888003,
      "median": 0.28517170948000004,
      "user": 0.2188765,
      "system": 0.5576753799999998,
      "min": 0.25749809948,
      "max": 0.33777600148000003,
      "times": [
        0.25749809948,
        0.26731810948,
        0.28502685548,
        0.29517284348000006,
        0.31836374948,
        0.27451212348000004,
        0.28531656348,
        0.28918446648,
        0.33777600148000003,
        0.27873112948
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.001 ± 0.067 1.929 2.123 7.82 ± 0.38
pacquet@main 1.955 ± 0.113 1.837 2.123 7.64 ± 0.52
pnpr@HEAD 0.256 ± 0.009 0.241 0.268 1.00
pnpr@main 0.270 ± 0.010 0.259 0.290 1.06 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.0014207332200002,
      "stddev": 0.06714640619253742,
      "median": 1.98849445012,
      "user": 1.14612506,
      "system": 0.7990220399999999,
      "min": 1.92854193262,
      "max": 2.12262319962,
      "times": [
        1.92930521462,
        2.03483956462,
        2.00025774062,
        2.12262319962,
        2.0595774426199998,
        1.92854193262,
        1.9298099576199998,
        1.96779789162,
        2.06472322862,
        1.97673115962
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.95545557312,
      "stddev": 0.1133890131392561,
      "median": 1.9086505971199998,
      "user": 1.09043706,
      "system": 0.7951143399999999,
      "min": 1.83723983862,
      "max": 2.12261554462,
      "times": [
        2.0528476156199997,
        2.12261554462,
        2.04715174062,
        2.10513010662,
        1.91856490162,
        1.89873629262,
        1.83723983862,
        1.84973784562,
        1.86009998062,
        1.86243186462
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.25606693662,
      "stddev": 0.009041993206086363,
      "median": 0.25821139912,
      "user": 0.18810126,
      "system": 0.54376874,
      "min": 0.24111840962000003,
      "max": 0.26809164962,
      "times": [
        0.25674970362,
        0.24632427962000003,
        0.24111840962000003,
        0.24658047162000002,
        0.26123715662,
        0.26809164962,
        0.26234772362,
        0.25284534062,
        0.25967309462,
        0.26570153662
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27021144262,
      "stddev": 0.010474208753177323,
      "median": 0.26546328661999996,
      "user": 0.18969266,
      "system": 0.5585242400000001,
      "min": 0.25934618662,
      "max": 0.29016279262,
      "times": [
        0.27851555162,
        0.26520785362,
        0.25934618662,
        0.28440440962,
        0.26428966062,
        0.26174125762,
        0.26571871962,
        0.26326278162,
        0.26946521262,
        0.29016279262
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 358.0 ± 15.5 325.5 383.3 4.34 ± 0.21
pacquet@main 384.6 ± 30.4 341.4 434.9 4.67 ± 0.38
pnpr@HEAD 84.9 ± 2.7 80.2 93.5 1.03 ± 0.04
pnpr@main 82.4 ± 1.9 80.0 88.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.35797210244,
      "stddev": 0.01548925523570165,
      "median": 0.36078916674000006,
      "user": 0.36207178,
      "system": 0.0451887,
      "min": 0.32548806824000004,
      "max": 0.38334154424000005,
      "times": [
        0.36433850324000006,
        0.36096691724,
        0.37146472824000004,
        0.36061141624000004,
        0.34803121224000005,
        0.32548806824000004,
        0.35283058424,
        0.34957026824000004,
        0.36307778224000004,
        0.38334154424000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.38458171313999995,
      "stddev": 0.03044595425447092,
      "median": 0.38443965224000004,
      "user": 0.36666018000000006,
      "system": 0.07275709999999999,
      "min": 0.34138047424000006,
      "max": 0.43493543024000003,
      "times": [
        0.37935708024000003,
        0.35422624924,
        0.38952222424000005,
        0.34138047424000006,
        0.42420073124,
        0.40295331324000006,
        0.35600839524000005,
        0.37097703724000003,
        0.43493543024000003,
        0.39225619624
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08492602217939396,
      "stddev": 0.0027105877456634277,
      "median": 0.08520630724000001,
      "user": 0.01533348303030303,
      "system": 0.012304560606060604,
      "min": 0.08020897224000001,
      "max": 0.09353794824,
      "times": [
        0.08539008524000001,
        0.09037781224000001,
        0.08487352924000001,
        0.08593381124,
        0.08197567724,
        0.08700416224,
        0.08393765224000001,
        0.08318683424000001,
        0.08230819524,
        0.08665637424000001,
        0.08563338524000001,
        0.08284620124000001,
        0.08447530624,
        0.08137959224,
        0.08115028824000001,
        0.08313816224000001,
        0.08020897224000001,
        0.08635656024,
        0.09353794824,
        0.08761685824000001,
        0.08530464324,
        0.08366898424000001,
        0.08615409724,
        0.08582156024000001,
        0.08029837024000001,
        0.08354455924000001,
        0.08555218024000001,
        0.08440389324000001,
        0.08504216724000001,
        0.08520630724000001,
        0.08708607724,
        0.08661053924,
        0.08587794524
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08243097738705882,
      "stddev": 0.0018725270352886395,
      "median": 0.08203706324000001,
      "user": 0.015997532941176475,
      "system": 0.010701779411764702,
      "min": 0.08002324024,
      "max": 0.08834782024000001,
      "times": [
        0.08277996624,
        0.08333065524000001,
        0.08379078424000001,
        0.08208699824000001,
        0.08297765924,
        0.08743815124000001,
        0.08321373524,
        0.08137302924,
        0.08283192424000001,
        0.08629014324,
        0.08834782024000001,
        0.08245895924,
        0.08218368024,
        0.08062821424000001,
        0.08121312724,
        0.08340275224,
        0.08142934524,
        0.08111268924000001,
        0.08138992124000001,
        0.08284736324000001,
        0.08023914824,
        0.08146279024000001,
        0.08411690024000001,
        0.08002324024,
        0.08232772224000001,
        0.08162268124000001,
        0.08198712824000001,
        0.08114736324,
        0.08089204124,
        0.08285322524000001,
        0.08058193524000001,
        0.08142603924000001,
        0.08149679224,
        0.08134930524
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.807 ± 0.165 4.544 5.047 1.36 ± 0.06
pacquet@main 4.869 ± 0.316 4.519 5.391 1.37 ± 0.10
pnpr@HEAD 3.545 ± 0.104 3.464 3.816 1.00
pnpr@main 3.598 ± 0.116 3.503 3.898 1.01 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.807281425579999,
      "stddev": 0.16532254043799186,
      "median": 4.80331910938,
      "user": 2.6859432599999997,
      "system": 1.9109594800000003,
      "min": 4.54391178238,
      "max": 5.0469261023800005,
      "times": [
        4.75084614738,
        4.58296025138,
        4.54391178238,
        4.81403889538,
        4.89931637238,
        5.01454245638,
        4.79259932338,
        4.73043658038,
        4.89723634438,
        5.0469261023800005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.868555273579999,
      "stddev": 0.3162215318207752,
      "median": 4.7734213393800005,
      "user": 2.75552086,
      "system": 1.98703528,
      "min": 4.51929912338,
      "max": 5.39069923938,
      "times": [
        5.22503447238,
        5.26067393738,
        5.39069923938,
        4.77963827338,
        4.5998333133800005,
        4.90851121938,
        4.56120110638,
        4.76720440538,
        4.51929912338,
        4.67345764538
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5450737794800005,
      "stddev": 0.10447751725976809,
      "median": 3.51312856038,
      "user": 1.3045088599999999,
      "system": 1.36957978,
      "min": 3.46449992138,
      "max": 3.81602442338,
      "times": [
        3.5186110683800003,
        3.4882485453800003,
        3.81602442338,
        3.46449992138,
        3.4752616933800002,
        3.57878295838,
        3.50764605238,
        3.48467710138,
        3.51985752138,
        3.59712850938
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.59782816598,
      "stddev": 0.11644105422791955,
      "median": 3.5651825278800002,
      "user": 1.4736647599999997,
      "system": 1.45380108,
      "min": 3.50286892138,
      "max": 3.89807515338,
      "times": [
        3.51634686238,
        3.5065915313800002,
        3.62563484738,
        3.6149694083800004,
        3.63722412238,
        3.54965174338,
        3.89807515338,
        3.50286892138,
        3.5807133123800003,
        3.54620575738
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13029
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,124.26 ms
(-24.03%)Baseline: 4,112.68 ms
4,935.21 ms
(63.31%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,001.42 ms
(-30.69%)Baseline: 2,887.74 ms
3,465.29 ms
(57.76%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
666.87 ms
(-47.79%)Baseline: 1,277.37 ms
1,532.84 ms
(43.51%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
357.97 ms
(-40.08%)Baseline: 597.37 ms
716.84 ms
(49.94%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,624.27 ms
(-29.24%)Baseline: 3,708.46 ms
4,450.15 ms
(58.97%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,807.28 ms
(-29.96%)Baseline: 6,863.87 ms
8,236.64 ms
(58.36%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
292.83 ms
(-51.61%)Baseline: 605.12 ms
726.15 ms
(40.33%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 15, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13029
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,570.72 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
256.07 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
271.88 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.93 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,577.08 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,545.07 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
275.52 ms
🐰 View full continuous benchmarking report in Bencher

@Andarist
Andarist marked this pull request as draft July 15, 2026 14:04
@Andarist
Andarist marked this pull request as ready for review July 15, 2026 16:41
@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 15, 2026
@zkochan
zkochan force-pushed the fix/json-errors-rust branch from fecba0e to 379d8b9 Compare July 15, 2026 19:16
@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset lists only pacquet and omits the required pnpm entry, so the release tooling
will not apply the mandated pnpm bump type. This violates the changeset policy and can cause
incorrect versioning/release notes.
Code

.changeset/pacquet-publish-json-errors.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires each changeset to explicitly include a pnpm entry 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/pacquet-publish-json-errors.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 new changeset file does not include a `pnpm` entry in the front-matter.

## Issue Context
Compliance requires every changeset to explicitly declare a `pnpm` bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/pacquet-publish-json-errors.md[1-3]

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


2. Clippy exit lint failure 🐞 Bug ☼ Reliability
Description
dispatch.rs introduces new std::process::exit(1) calls without #[expect(clippy::exit)], but
the workspace enables clippy::exit = "warn" and CI runs clippy with -D warnings, so this change
will fail the clippy job. Additionally, exiting here bypasses normal unwinding/cleanup semantics,
which is risky in a CLI that may hold buffered IO and other RAII-managed resources at this point.
Code

pnpm/crates/cli/src/cli_args/dispatch.rs[R273-289]

+        match route(command, &ctx) {
+            Ok(future) => {
+                if let Err(error) = future.await {
+                    if print_json_errors {
+                        print_json_error(&error);
+                        std::process::exit(1);
+                    }
+                    return Err(error);
+                }
+            }
+            Err(error) => {
+                if print_json_errors {
+                    print_json_error(&error);
+                    std::process::exit(1);
+                }
+                return Err(error);
+            }
Evidence
The diff adds process::exit(1) in the JSON error path, while the workspace explicitly enables the
exit lint and CI runs clippy with -D warnings (so any new clippy warnings fail the build). Other
process::exit uses in this crate are already annotated, indicating the expected convention.

pnpm/crates/cli/src/cli_args/dispatch.rs[273-289]
Cargo.toml[208-266]
.github/workflows/pacquet-ci.yml[240-255]
pnpm/crates/cli/src/cli_args/dispatch_query.rs[55-105]

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

## Issue description
New `std::process::exit(1)` calls in the `publish --json` error path will trigger the workspace `clippy::exit` lint and fail CI because clippy warnings are denied.

## Issue Context
The repo config sets `clippy::exit = "warn"`, and the CI workflow runs `cargo clippy ... -- -D warnings`. Other `process::exit` call sites are annotated with `#[expect(clippy::exit, reason = ...)]`.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/dispatch.rs[273-289]
- Cargo.toml[208-266]
- .github/workflows/pacquet-ci.yml[240-255]
- pnpm/crates/cli/src/cli_args/dispatch_query.rs[55-105]

## Suggested fix direction
Either:
1) Replace `process::exit(1)` with a structured return path (e.g., return `Ok(())` plus a typed outcome/exit-code propagated to `pacquet_cli::main`, so the process exits after normal unwinding), OR
2) If early termination is required, add `#[expect(clippy::exit, reason = "...")]` at each `process::exit` call site (matching existing patterns) and ensure stdout is explicitly flushed before exiting to keep the JSON envelope reliable under piping/capture.

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



Remediation recommended

3. Brittle pack-context matching ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
json_error_message() changes the JSON error message based on an exact string match of the outer
context message ("pack the package"), coupling machine-readable output to a human-readable phrase.
Any future refactor/renaming of that context string will silently change publish --json error
output and potentially break consumers relying on stable messages.
Code

pnpm/crates/cli/src/cli_args/dispatch.rs[R422-428]

+fn json_error_message(error: &miette::Report) -> String {
+    let mut messages = error.chain().map(ToString::to_string);
+    match (messages.next(), messages.next()) {
+        (Some(context), Some(source)) if context == "pack the package" => source,
+        (Some(message), _) => message,
+        (None, _) => error.to_string(),
+    }
Evidence
The new logic explicitly compares the first chained message to a hard-coded string, and the publish
pack pipeline currently injects that exact string via wrap_err, demonstrating the coupling point.

pnpm/crates/cli/src/cli_args/dispatch.rs[422-429]
pnpm/crates/cli/src/cli_args/publish.rs[320-325]

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

## Issue description
`json_error_message()` relies on `context == "pack the package"` to decide whether to unwrap to the next error in the chain. This is fragile because it depends on a specific display string staying unchanged.

## Issue Context
That context string currently comes from `pack_for_publish()` using `.wrap_err("pack the package")`. String-coupling makes regressions easy when text changes for readability.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/dispatch.rs[422-429]
- pnpm/crates/cli/src/cli_args/publish.rs[320-325]

## Suggested fix direction
Replace the string match with a stable discriminator, e.g.:
- introduce a small typed wrapper error for the pack step and detect it via `downcast_ref`, or
- key off a stable diagnostic code instead of display text,
so the JSON message contract doesn’t depend on a literal English string.

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


Grey Divider

Qodo Logo

Comment on lines +1 to +3
---
"pacquet": patch
---

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Changeset missing pnpm bump 📘 Rule violation § Compliance

The new changeset lists only pacquet and omits the required pnpm entry, so the release tooling
will not apply the mandated pnpm bump type. This violates the changeset policy and can cause
incorrect versioning/release notes.
Agent Prompt
## Issue description
The new changeset file does not include a `pnpm` entry in the front-matter.

## Issue Context
Compliance requires every changeset to explicitly declare a `pnpm` bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/pacquet-publish-json-errors.md[1-3]

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

Comment on lines +273 to +289
match route(command, &ctx) {
Ok(future) => {
if let Err(error) = future.await {
if print_json_errors {
print_json_error(&error);
std::process::exit(1);
}
return Err(error);
}
}
Err(error) => {
if print_json_errors {
print_json_error(&error);
std::process::exit(1);
}
return Err(error);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Clippy exit lint failure 🐞 Bug ☼ Reliability

dispatch.rs introduces new std::process::exit(1) calls without #[expect(clippy::exit)], but
the workspace enables clippy::exit = "warn" and CI runs clippy with -D warnings, so this change
will fail the clippy job. Additionally, exiting here bypasses normal unwinding/cleanup semantics,
which is risky in a CLI that may hold buffered IO and other RAII-managed resources at this point.
Agent Prompt
## Issue description
New `std::process::exit(1)` calls in the `publish --json` error path will trigger the workspace `clippy::exit` lint and fail CI because clippy warnings are denied.

## Issue Context
The repo config sets `clippy::exit = "warn"`, and the CI workflow runs `cargo clippy ... -- -D warnings`. Other `process::exit` call sites are annotated with `#[expect(clippy::exit, reason = ...)]`.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/dispatch.rs[273-289]
- Cargo.toml[208-266]
- .github/workflows/pacquet-ci.yml[240-255]
- pnpm/crates/cli/src/cli_args/dispatch_query.rs[55-105]

## Suggested fix direction
Either:
1) Replace `process::exit(1)` with a structured return path (e.g., return `Ok(())` plus a typed outcome/exit-code propagated to `pacquet_cli::main`, so the process exits after normal unwinding), OR
2) If early termination is required, add `#[expect(clippy::exit, reason = "...")]` at each `process::exit` call site (matching existing patterns) and ensure stdout is explicitly flushed before exiting to keep the JSON envelope reliable under piping/capture.

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

@qodo-code-review

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to e2566f5

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Cover all command setup failures

Wrap the entire command execution, including setup, in a JSON error handler.
This ensures all errors are correctly formatted as JSON when the --json flag is
used.

pnpm/crates/cli/src/cli_args/dispatch.rs [273-290]

-match route(command, &ctx) {
-    Ok(future) => {
-        if let Err(error) = future.await {
-            if print_json_errors {
-                print_json_error(&error);
-                std::process::exit(1);
-            }
-            return Err(error);
-        }
+let result = self.run_inner(config_overrides).await;
+if let Err(error) = result {
+    if print_json_errors {
+        print_json_error(&error);
+        std::process::exit(1);
     }
-    Err(error) => {
-        if print_json_errors {
-            print_json_error(&error);
-            std::process::exit(1);
-        }
-        return Err(error);
-    }
+    return Err(error);
 }
  • Apply / Chat
Suggestion importance[1-10]: 8

__

Why: This suggestion addresses a critical logical gap where early setup errors would bypass the newly implemented JSON error formatting, ensuring consistency with the PR's stated goals.

Medium
General
Preserve cleanup on JSON failures

Replace std::process::exit with a dedicated error return to allow destructors to
run. Handle the error formatting and exit status at the top level of the
application.

pnpm/crates/cli/src/cli_args/dispatch.rs [276-279]

 if print_json_errors {
     print_json_error(&error);
-    std::process::exit(1);
+    return Err(JsonErrorAlreadyRendered.into());
 }
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: Avoiding std::process::exit is a good Rust practice to ensure destructors run and resources are cleaned up properly, though for a short-lived CLI tool the immediate impact is moderate.

Low
  • More

Previous suggestions

Suggestions up to commit 379d8b9
CategorySuggestion                                                                                                                                    Impact
Possible issue
Flush JSON before process termination

Explicitly flush stdout when printing the JSON error envelope.

pnpm/crates/cli/src/cli_args/dispatch.rs [418-419]

 let output = serde_json::to_string(&output).expect("a JSON error envelope serializes");
-println!("{output}");
+let mut stdout = std::io::stdout().lock();
+std::io::Write::write_all(&mut stdout, output.as_bytes())
+    .expect("write JSON error envelope");
+std::io::Write::write_all(&mut stdout, b"\n")
+    .expect("terminate JSON error envelope");
+std::io::Write::flush(&mut stdout).expect("flush JSON error envelope");
Suggestion importance[1-10]: 9

__

Why: Addresses a critical bug where JSON error output is lost when redirected or piped because std::process::exit aborts before the stdout buffer flushes.

High

…pnpm

pnpm's errorHandler prints the failure envelope with
JSON.stringify(_, null, 2), so pacquet must emit the same two-space
indentation to stay byte-for-byte identical. Restore to_string_pretty;
a prior review suggestion had switched it to compact output, which
diverged from pnpm.

Also share the "pack the package" wrap_err context through a single
PACK_ERROR_CONTEXT const so the pack/publish wrap sites and the dispatch
JSON matcher can't drift apart.
@qodo-code-review

Copy link
Copy Markdown

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

@zkochan zkochan changed the title Changed pacquet publish --json failures to match pnpm's JSON error output fix(cli): match pnpm's JSON error output for publish --json failures Jul 15, 2026
@zkochan
zkochan merged commit 888a6f3 into pnpm:main Jul 15, 2026
30 checks passed
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.

3 participants