Skip to content

fix(cli): honor unused-patch overrides - #14459

Merged
zkochan merged 2 commits into
mainfrom
fix-14450
Sep 2, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-14450

Conversation

@zkochan

@zkochan zkochan commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Honor allowUnusedPatches in the Rust pnpm CLI when it is supplied through
    --config.allow-unused-patches or the pnpm-specific
    PNPM_CONFIG_ALLOW_UNUSED_PATCHES/pnpm_config_allow_unused_patches
    environment variable.
  • Record the command-line override as an explicit setting and cover both
    configuration paths with unit and deploy --legacy regression tests.
  • This is Rust-only: the frozen TypeScript v11 CLI already honors the relevant
    override path. General npm_config_* settings remain intentionally unsupported
    by the Rust CLI; the issue's v11 no-setting case also succeeds, so it does not
    establish that namespace as the cause of the version difference.

Fixes #14450.

Squash Commit Body

Apply allowUnusedPatches from dotted command-line overrides and the
pnpm-specific configuration environment before dispatching commands. This
keeps legacy deploys from rejecting patches that belong only to projects
outside the selected deployment subset.

Add parser and environment unit coverage together with a legacy deploy
regression test for both supported override paths.

Fixes pnpm/pnpm#14450.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • 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 (Codex, GPT-5).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed legacy pnpm deploy so it honors the allow-unused-patches setting provided through CLI configuration or the PNPM_CONFIG_ALLOW_UNUSED_PATCHES environment variable.
    • Added support for common boolean forms, including true, false, 1, 0, and the --no-allow-unused-patches flag.
  • Tests

    • Added coverage confirming the setting is correctly read, applied, and preserved across supported configuration sources.

Apply allowUnusedPatches from dotted command-line overrides and the
PNPM_CONFIG_ALLOW_UNUSED_PATCHES environment variable before dispatching
commands. Add parser, environment, and legacy deploy regression coverage.

Fixes #14450.
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Honor unused-patch CLI and environment overrides

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Honor CLI and pnpm-specific environment overrides for allowUnusedPatches in the Rust CLI.
• Preserve explicit-setting precedence before legacy deploy patch validation.
• Add parser, environment, deploy regression coverage, and release notes.
Diagram

graph TD
  CLI["CLI Override"] --> Parser["Config Overrides"] --> Config["Runtime Config"] --> Deploy["Legacy Deploy"] --> Check{"Unused Patch?"} --> Success["Allow Deployment"]
  Env["PNPM Config Env"] --> Overlay["Environment Overlay"] --> Config
Loading
High-Level Assessment

The PR uses the existing CLI override and environment-overlay mechanisms, preserving established configuration precedence and explicit-setting semantics. Broadening support to generic npm_config_* variables would be a larger compatibility change unsupported by the reported failure, so the focused pnpm-specific fix is preferable.

Files changed (6) +89 / -0

Bug fix (2) +7 / -0
config_overrides.rsApply allowUnusedPatches command-line overrides +6/-0

Apply allowUnusedPatches command-line overrides

• Parses 'allow-unused-patches' from dotted configuration arguments and applies it to runtime configuration. Records the camel-cased key in 'explicit_settings' so downstream logic recognizes the value as user-supplied.

pnpm/crates/cli/src/config_overrides.rs

env_overlay.rsRead allowUnusedPatches from pnpm environment +1/-0

Read allowUnusedPatches from pnpm environment

• Maps the pnpm-specific 'ALLOW_UNUSED_PATCHES' environment suffix into workspace settings, supporting both recognized PNPM_CONFIG variable casing paths through the existing overlay mechanism.

pnpm/crates/config/src/env_overlay.rs

Tests (3) +77 / -0
tests.rsTest unused-patch command-line override parsing +28/-0

Test unused-patch command-line override parsing

• Verifies both true and false command-line values override existing configuration and are recorded as explicit settings.

pnpm/crates/cli/src/config_overrides/tests.rs

patch.rsCover legacy deploy override paths +37/-0

Cover legacy deploy override paths

• Adds an end-to-end regression test proving filtered legacy deploys succeed with unused patches when enabled through either the dotted CLI option or 'PNPM_CONFIG_ALLOW_UNUSED_PATCHES'.

pnpm/crates/cli/tests/suite/patch.rs

tests.rsTest unused-patch environment materialization +12/-0

Test unused-patch environment materialization

• Verifies 'PNPM_CONFIG_ALLOW_UNUSED_PATCHES=true' materializes as an enabled workspace setting.

pnpm/crates/config/src/env_overlay/tests.rs

Documentation (1) +5 / -0
allow-unused-patches-overrides.mdDocument unused-patch override support +5/-0

Document unused-patch override support

• Adds a patch release note explaining that legacy deploy now honors command-line and pnpm-specific environment overrides for 'allowUnusedPatches'.

.changeset/allow-unused-patches-overrides.md

@coderabbitai

coderabbitai Bot commented Sep 2, 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: Team

Run ID: ceae1dd0-1a47-4544-b0ad-a3359af208b9

📥 Commits

Reviewing files that changed from the base of the PR and between 640596b and dcd998a.

📒 Files selected for processing (2)
  • pnpm/crates/cli/src/config_overrides.rs
  • pnpm/crates/cli/src/config_overrides/tests.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The change makes allowUnusedPatches available through CLI and environment overrides. Tests cover option parsing, environment loading, and legacy deploy behavior.

Changes

Allow unused patches overrides

Layer / File(s) Summary
CLI override application
pnpm/crates/cli/src/config_overrides.rs, pnpm/crates/cli/src/config_overrides/tests.rs
The CLI parses valid allow-unused-patches forms, applies the boolean value, records the explicit setting, and leaves invalid values for clap.
Environment override application
pnpm/crates/config/src/env_overlay.rs, pnpm/crates/config/src/env_overlay/tests.rs
The environment overlay reads PNPM_CONFIG_ALLOW_UNUSED_PATCHES and stores its JSON-parsed value.
Legacy deploy regression coverage
pnpm/crates/cli/tests/suite/patch.rs, .changeset/allow-unused-patches-overrides.md
The legacy deploy test covers CLI and environment overrides. The changeset declares a patch release for pacquet.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to dcd99

This PR enables the existing unused-patch behavior through two supported Rust CLI configuration paths and adds regression coverage; no actionable merge-blocking risk remains beyond normal checks and review.

Assessment against linked issues

Objective Addressed Explanation
Honor allowUnusedPatches for deploy --legacy when supplied through --config.allow-unused-patches or PNPM_CONFIG_ALLOW_UNUSED_PATCHES [#14450] ✅

Suggested labels: product: pacquet

Suggested reviewers: stanzilla, ayush442842q, lazerg

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-14450

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.

@greptile-apps

greptile-apps Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (2): Last reviewed commit: "fix(cli): validate unused-patch override..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Sep 2, 2026
@qodo-code-review

qodo-code-review Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Invalid override is swallowed ✓ Resolved 🐞 Bug ≡ Correctness
Description
--config.allow-unused-patches=yes or an empty value is consumed even though parse_bool rejects
it, so clap cannot report the invalid argument. The command then proceeds with the default or
lower-priority setting, potentially producing unexpected unused-patch validation results.
Code

pnpm/crates/cli/src/config_overrides.rs[225]

+            "allow-unused-patches" => self.allow_unused_patches = parse_bool(value),
Relevance

●●● Strong

PR #14236 accepted the identical silent-consumption defect for invalid boolean config overrides.

PR-#14236

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Config-prefixed tokens are accepted only according to setting_takes, but that function accepts
every value for keys absent from BARE_SETTING_FLAGS. Because the new key is absent from that
table, set receives invalid values, converts them to None, and the extraction loop drops the
already-consumed token; the existing shamefully-hoist test demonstrates the intended behavior for
known booleans. PR #14236 previously fixed the identical silent-consumption pattern for another
boolean override.

pnpm/crates/cli/src/config_overrides.rs[198-217]
pnpm/crates/cli/src/config_overrides.rs[707-719]
pnpm/crates/cli/src/config_overrides.rs[770-817]
pnpm/crates/cli/src/config_overrides/tests.rs[113-127]
PR-#14236

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

## Issue description
Invalid or empty `--config.allow-unused-patches` values are consumed and silently discarded. They must remain in argv so clap reports the invalid argument rather than running with an unintended configuration.

## Issue Context
`setting_takes` validates known boolean settings, but `allow-unused-patches` is not registered in the setting metadata. Add boolean validation and regression coverage for values such as `yes` and an empty string; registering it in the existing boolean setting table may also provide the standard bare boolean spellings.

## Fix Focus Areas
- pnpm/crates/cli/src/config_overrides.rs[707-817]
- pnpm/crates/cli/src/config_overrides/tests.rs[113-127]
- pnpm/crates/cli/src/config_overrides/tests.rs[405-431]

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



Informational

2. pnpm missing from changeset 📘 Rule violation § Compliance
Description
The new changeset declares only pacquet, omitting the required pnpm package entry. Because this
is a bug fix, pnpm must be explicitly listed with a patch bump.
Code

.changeset/allow-unused-patches-overrides.md[2]

+"pacquet": patch
Relevance

● Weak

Recent closely matching changeset compliance findings were rejected, including PRs #14435 and
#14420.

PR-#14435
PR-#14420

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires every new or modified changeset to explicitly declare pnpm with a
valid bump type. The new front matter contains only "pacquet": patch.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/allow-unused-patches-overrides.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 omits the required `pnpm` package declaration.

## Issue Context
This PR fixes user-visible CLI behavior, so the changeset must explicitly include `pnpm` with a `patch` bump. Retain other affected package entries as appropriate.

## Fix Focus Areas
- .changeset/allow-unused-patches-overrides.md[1-3]

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


Grey Divider

Context sources
✅ Compliance rules (platform): 27 rules
Review mode: 🚀 Fast: This is a localized CLI boolean-override change with focused unit coverage and no security, performance, or broad behavioral risk.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

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

Register allow-unused-patches as a boolean setting so invalid values remain
in argv for clap to reject. Cover bare, negated, numeric, dotted, and
invalid spellings.
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     13.5±0.66ms    27.7 MB/sec    1.05     14.2±2.48ms    26.4 MB/sec
packument/parse                                  1.00     40.2±0.28µs  1649.7 MB/sec    1.04     41.8±0.30µs  1585.6 MB/sec
tarball/download_dependency                      1.01      4.3±0.36ms  1013.9 KB/sec    1.00      4.2±0.54ms  1023.6 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.16   209.7±12.63ms 76.3 KElem/sec    1.00    181.0±5.08ms 88.4 KElem/sec
workspace_resolution/hoist_heavy                 1.04   313.9±30.87ms        ? ?/sec    1.00   302.0±17.33ms        ? ?/sec
workspace_sort/chained_projects                  1.13     13.7±1.12ms        ? ?/sec    1.00     12.1±0.59ms        ? ?/sec

@greptile-apps
greptile-apps Bot dismissed their stale review September 2, 2026 12:47

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@zkochan

zkochan commented Sep 2, 2026

Copy link
Copy Markdown
Member Author

Addressed the invalid-boolean finding in commit dcd998abea: allow-unused-patches is now registered as a boolean setting, so invalid and empty values stay in argv for clap to reject. The expanded tests cover bare, negated, numeric, dotted, invalid, and empty spellings.

The changeset finding does not apply to this PR. This is a Rust-only change, and the repository instructions explicitly require the pacquet package name while prohibiting the TypeScript pnpm package in Rust-only changesets.


Written by an agent (Codex, GPT-5).

@qodo-code-review

Copy link
Copy Markdown

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

@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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.85%. Comparing base (1d00e70) to head (dcd998a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14459      +/-   ##
==========================================
- Coverage   88.85%   88.85%   -0.01%     
==========================================
  Files         703      703              
  Lines      125944   125950       +6     
==========================================
+ Hits       111912   111916       +4     
- Misses      14032    14034       +2     

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

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 deploy --legacy ignores allowUnusedPatches passed via --config. or npm_config_ on pnpm 12 (only pnpm-workspace.yaml is honoured)

2 participants