Skip to content

fix(config): do not expand env vars in a project-level userAgent - #15419

Merged
zkochan merged 3 commits into
mainfrom
fix-15415
Sep 23, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-15415

Conversation

@zkochan

@zkochan zkochan commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

A userAgent set in a repository's pnpm-workspace.yaml had its ${VAR} placeholders resolved against the installer's environment and sent as the User-Agent header to a registry that the same file can name. This PR treats userAgent like the request-destination settings: a placeholder in it is dropped when the file is repository-controlled. It stays expanded from trusted sources.

  • v11: userAgent is added to the scalar set gated by expandRequestDestinationEnv. The set is renamed REQUEST_SCALAR_KEYS because it now covers "what goes with a request" as well as "where it goes".
  • v12: user_agent moves out of substitute_env_scalars into substitute_env_trusted, and substitute_env_untrusted drops it when it holds a placeholder. It shares the filter loop with pnprServer and the proxies.

The issue also asks for a review of other settings that go out with a request. I checked the string settings both stacks expand from a project file (scriptShell, nodeOptions, the directory settings, npmrcAuthFile). None of them is sent in a request, and auth values are already gated separately. So this PR only covers userAgent.

Closes #15415

Squash Commit Body

A `userAgent` in a repository's pnpm-workspace.yaml had its `${VAR}`
placeholders resolved and sent as the User-Agent header to the registry,
which the same file can choose with a literal `registry:`. That let a
repository deliver an installer's environment variable (a token, say) to
a host it names, without any lifecycle script.

`userAgent` now joins the request settings whose placeholders are dropped
when the file is repository-controlled: `REQUEST_SCALAR_KEYS` in v11, and
the filtered scalars of `substitute_env_untrusted` in v12. Trusted sources
(the global config and the environment overlay) still expand it.

Closes pnpm/pnpm#15415

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • 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.

🤖 Generated with Claude Code


Written by an agent (Claude Code, claude-opus-5-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
    • Environment-variable placeholders in workspace userAgent settings are now ignored by default, preventing installer environment values from being included in request headers. Literal userAgent values remain unchanged.
    • When environment expansion is explicitly enabled in a trusted context, placeholders in userAgent settings are still expanded.
  • Tests
    • Added coverage for default placeholder handling, preservation of literal values, and expansion when enabled.

A `userAgent` in a repository's pnpm-workspace.yaml had its `${VAR}`
placeholders resolved and sent as the User-Agent header to the registry,
which the same file can choose with a literal `registry:`. That let a
repository deliver an installer's environment variable (a token, say) to
a host it names, without any lifecycle script.

`userAgent` now joins the request settings whose placeholders are dropped
when the file is repository-controlled: `REQUEST_SCALAR_KEYS` in v11, and
the filtered scalars of `substitute_env_untrusted` in v12. Trusted sources
(the global config and the environment overlay) still expand it.

Closes #15415

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: cc8adcf8-71a9-4164-b1d2-05eebd5e5602

📥 Commits

Reviewing files that changed from the base of the PR and between 5219d2d and c646edd.

📒 Files selected for processing (1)
  • .changeset/workspace-user-agent-env.md

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: b9707e2f-2531-4ca3-ae8d-0580217eb617

📥 Commits

Reviewing files that changed from the base of the PR and between f5fbf6b and 5219d2d.

📒 Files selected for processing (5)
  • .changeset/workspace-user-agent-env.md
  • pnpm/crates/config/src/workspace_yaml/env.rs
  • pnpm/crates/config/src/workspace_yaml/tests/workspace_settings.rs
  • pnpm11/config/reader/src/getOptionsFromRootManifest.ts
  • pnpm11/config/reader/test/getOptionsFromRootManifest.test.ts

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


📝 Walkthrough

Walkthrough

The Rust and TypeScript configuration paths now filter environment-variable placeholders in workspace userAgent values when environment expansion is untrusted. Trusted expansion remains available. Tests cover placeholder values, literal values, and trusted expansion.

Changes

Workspace userAgent environment handling

Layer / File(s) Summary
Rust workspace environment handling
pnpm/crates/config/src/workspace_yaml/env.rs, pnpm/crates/config/src/workspace_yaml/tests/workspace_settings.rs
The untrusted path clears user_agent values with placeholders. The trusted path expands them. Tests cover placeholder values, literal values, and trusted expansion.
TypeScript root manifest handling
pnpm11/config/reader/src/getOptionsFromRootManifest.ts, pnpm11/config/reader/test/getOptionsFromRootManifest.test.ts, .changeset/workspace-user-agent-env.md
The reader skips placeholder-containing userAgent values when expandRequestDestinationEnv is disabled. Tests cover that case, literal values, and enabled expansion. A patch changeset records the release note.

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

Assessment against linked issues

Objective Addressed Explanation
Prevent environment placeholders in repository-controlled userAgent values from being expanded in both configuration implementations [#15415] ✅
Allow trusted configuration to expand userAgent environment placeholders [#15415] ✅

Suggested labels: product: pnpm@11, product: pacquet

Merge Risk: ⚪ Minimal · up to 5219d

Project-controlled userAgent placeholders are filtered while trusted configuration retains expansion. No actionable merge-blocking risk is established.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     14.2±1.84ms    26.5 MB/sec    1.04     14.7±1.37ms    25.5 MB/sec
packument/parse                                  1.04     45.1±7.65µs  1469.4 MB/sec    1.00     43.6±3.81µs  1522.0 MB/sec
tarball/download_dependency                      1.00      4.4±0.27ms   992.4 KB/sec    1.38      6.0±1.21ms   717.2 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   236.8±16.32ms 67.6 KElem/sec    1.06   250.5±12.62ms 63.9 KElem/sec
workspace_resolution/hoist_heavy                 1.00   269.6±29.19ms        ? ?/sec    1.17    316.2±8.70ms        ? ?/sec
workspace_sort/chained_projects                  1.00     15.2±1.76ms        ? ?/sec    1.18     18.0±2.96ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.78%. Comparing base (f5fbf6b) to head (c646edd).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15419      +/-   ##
==========================================
+ Coverage   91.76%   91.78%   +0.01%     
==========================================
  Files        1408     1408              
  Lines      189627   190236     +609     
==========================================
+ Hits       174019   174600     +581     
- Misses      15608    15636      +28     

☔ 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

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2508.75 ms 2495.38 ms -0.5% 125.44 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1456.36 ms 1382.14 ms -5.1% 72.82 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 427.89 ms 425.52 ms -0.6% 21.39 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 447.91 ms 471.22 ms 5.2% 22.40 ms Inconclusive (overlapping samples)
isolated-repeat-install-hot-cache-hot-store pacquet 18.15 ms 18.77 ms 3.4% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 13.29 ms 13.24 ms -0.4% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 19.25 ms 18.66 ms -3.1% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 17.13 ms 18.57 ms 8.4% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2718.03 ms 2773.43 ms 2.0% 135.90 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1531.95 ms 1556.73 ms 1.6% 76.60 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 452.45 ms 509.94 ms 12.7% 22.62 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pnpr 305.08 ms 385.04 ms 26.2% 15.25 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-hot-store pacquet 1767.04 ms 1707.31 ms -3.4% 88.35 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 381.66 ms 338.80 ms -11.2% 19.08 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 382.29 ms 434.86 ms 13.8% 19.11 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 118.95 ms 117.91 ms -0.9% 5.95 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 780.50 ms 737.37 ms -5.5% 39.02 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 243.12 ms 233.92 ms -3.8% 12.16 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 5121.71 ms 4941.36 ms -3.5% 256.09 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3579.93 ms 3563.49 ms -0.5% 179.00 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 184.90 ms 141.32 ms -23.6% 9.25 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 187.21 ms 190.14 ms 1.6% 9.36 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 5219d2d12ec6

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.547 ± 0.129 2.420 2.755 1.82 ± 0.14
pacquet@main 2.541 ± 0.122 2.433 2.828 1.81 ± 0.14
pnpr@HEAD 1.403 ± 0.080 1.322 1.592 1.00
pnpr@main 1.470 ± 0.086 1.365 1.688 1.05 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.54713077098,
      "stddev": 0.12876206490842146,
      "median": 2.49538093818,
      "user": 2.23491688,
      "system": 1.8521191799999996,
      "min": 2.42030838468,
      "max": 2.75539080568
    },
    {
      "command": "pacquet@main",
      "mean": 2.54147798428,
      "stddev": 0.12157786564553462,
      "median": 2.50874998668,
      "user": 2.1660473799999997,
      "system": 1.94079388,
      "min": 2.4331602926800002,
      "max": 2.8277024126800003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.40278968848,
      "stddev": 0.0801441651711667,
      "median": 1.3821412031800002,
      "user": 1.6182579799999999,
      "system": 1.5911641799999996,
      "min": 1.3223274096800002,
      "max": 1.5917312036800002
    },
    {
      "command": "pnpr@main",
      "mean": 1.4698248392800004,
      "stddev": 0.08648990494118,
      "median": 1.4563618061799999,
      "user": 1.5951882799999997,
      "system": 1.5480049799999995,
      "min": 1.36464523168,
      "max": 1.68832058468
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 407.7 ± 48.5 340.0 464.0 1.00
pacquet@main 449.9 ± 98.6 343.6 661.1 1.10 ± 0.28
pnpr@HEAD 489.7 ± 66.0 404.9 624.3 1.20 ± 0.22
pnpr@main 445.0 ± 49.1 367.0 521.8 1.09 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.40769519434,
      "stddev": 0.04850250508570887,
      "median": 0.42551673234000004,
      "user": 0.4243513,
      "system": 0.8116604800000001,
      "min": 0.34000613134,
      "max": 0.46400297334
    },
    {
      "command": "pacquet@main",
      "mean": 0.44987632884,
      "stddev": 0.09861395941782271,
      "median": 0.42789417234000005,
      "user": 0.4747179,
      "system": 0.8393909799999999,
      "min": 0.34362790934000004,
      "max": 0.6611349583400001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.4897481839400001,
      "stddev": 0.06595225741566921,
      "median": 0.47121536284000004,
      "user": 0.5097463999999999,
      "system": 0.8595478799999998,
      "min": 0.40487009434000004,
      "max": 0.6243246443400001
    },
    {
      "command": "pnpr@main",
      "mean": 0.44495625394000005,
      "stddev": 0.04911970533571454,
      "median": 0.44791425884,
      "user": 0.4505685,
      "system": 0.8107840799999998,
      "min": 0.36699386134,
      "max": 0.5218093353400001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 19.1 ± 4.0 11.3 29.4 1.40 ± 0.39
pacquet@main 18.5 ± 4.4 10.8 35.3 1.36 ± 0.40
pnpr@HEAD 13.8 ± 2.7 9.3 22.5 1.01 ± 0.27
pnpr@main 13.6 ± 2.5 9.4 22.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.019112922037647057,
      "stddev": 0.0040271743110353465,
      "median": 0.01876991492,
      "user": 0.009577875721925127,
      "system": 0.010641711443850269,
      "min": 0.011302458920000001,
      "max": 0.02939015692
    },
    {
      "command": "pacquet@main",
      "mean": 0.018507218399166664,
      "stddev": 0.004380062813213448,
      "median": 0.01815460092,
      "user": 0.00983052166666667,
      "system": 0.009764655833333337,
      "min": 0.010775122920000001,
      "max": 0.03526964992000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.013802391040171691,
      "stddev": 0.0026511206511207423,
      "median": 0.01323791292,
      "user": 0.007019492875536485,
      "system": 0.007689224892703864,
      "min": 0.00933018692,
      "max": 0.02251766092
    },
    {
      "command": "pnpr@main",
      "mean": 0.013647856193631841,
      "stddev": 0.0024671726605117656,
      "median": 0.013291523920000001,
      "user": 0.007353698905472635,
      "system": 0.007171864676616922,
      "min": 0.009449716920000002,
      "max": 0.02258571492
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 19.4 ± 3.2 14.0 32.8 1.13 ± 0.24
pacquet@main 19.5 ± 2.5 14.8 25.4 1.13 ± 0.21
pnpr@HEAD 18.9 ± 2.6 13.0 28.0 1.09 ± 0.21
pnpr@main 17.3 ± 2.3 10.5 23.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.0194496477653125,
      "stddev": 0.0032375545187204487,
      "median": 0.018661620320000002,
      "user": 0.011075719375000003,
      "system": 0.009507079687500003,
      "min": 0.014038443820000001,
      "max": 0.03283524882
    },
    {
      "command": "pacquet@main",
      "mean": 0.019513006256974795,
      "stddev": 0.002486979379841812,
      "median": 0.01924989282,
      "user": 0.0106970868907563,
      "system": 0.009916572268907565,
      "min": 0.01476004682,
      "max": 0.02543596982
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.018867386584705888,
      "stddev": 0.0026498615216286646,
      "median": 0.01856932232,
      "user": 0.010322227647058825,
      "system": 0.00963121764705882,
      "min": 0.01304445982,
      "max": 0.027955943820000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.017275702695000002,
      "stddev": 0.0022633372946521567,
      "median": 0.017134237320000002,
      "user": 0.009824952105263157,
      "system": 0.008566698026315793,
      "min": 0.010469633820000001,
      "max": 0.023647496820000002
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.770 ± 0.066 2.677 2.886 1.77 ± 0.15
pacquet@main 2.719 ± 0.051 2.643 2.827 1.74 ± 0.15
pnpr@HEAD 1.570 ± 0.054 1.486 1.663 1.00 ± 0.09
pnpr@main 1.563 ± 0.130 1.418 1.823 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7695718511600007,
      "stddev": 0.06648895276967365,
      "median": 2.7734328798600005,
      "user": 2.7555619399999998,
      "system": 2.22311886,
      "min": 2.67730541986,
      "max": 2.88567418986
    },
    {
      "command": "pacquet@main",
      "mean": 2.71880333446,
      "stddev": 0.05123112620503673,
      "median": 2.7180266628600003,
      "user": 2.5582411399999994,
      "system": 2.0945730599999997,
      "min": 2.6428727318600003,
      "max": 2.82732412486
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5701201019599997,
      "stddev": 0.05372948100306479,
      "median": 1.5567279463600001,
      "user": 1.5279314400000001,
      "system": 1.6907991599999996,
      "min": 1.48593803286,
      "max": 1.66310057186
    },
    {
      "command": "pnpr@main",
      "mean": 1.56337131566,
      "stddev": 0.129524249008444,
      "median": 1.53195156136,
      "user": 1.51371464,
      "system": 1.62347766,
      "min": 1.41781662286,
      "max": 1.8231940068599999
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 541.6 ± 137.1 396.3 816.1 1.73 ± 0.45
pacquet@main 469.0 ± 70.4 415.2 661.7 1.50 ± 0.24
pnpr@HEAD 379.8 ± 60.4 297.5 486.1 1.21 ± 0.21
pnpr@main 313.6 ± 18.8 295.6 337.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.54161781042,
      "stddev": 0.1370710760577367,
      "median": 0.50994200012,
      "user": 0.7878376799999999,
      "system": 0.9497916999999999,
      "min": 0.39626519362,
      "max": 0.81609622062
    },
    {
      "command": "pacquet@main",
      "mean": 0.46901590702000007,
      "stddev": 0.07039835294679508,
      "median": 0.45245158562000004,
      "user": 0.66784828,
      "system": 0.8723725,
      "min": 0.41523533662,
      "max": 0.66171223362
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.37975504522,
      "stddev": 0.06040351874805461,
      "median": 0.38504466262000003,
      "user": 0.32936518000000004,
      "system": 0.6792737999999999,
      "min": 0.29754089862000005,
      "max": 0.48610744962
    },
    {
      "command": "pnpr@main",
      "mean": 0.31356984532000004,
      "stddev": 0.018793101175142556,
      "median": 0.30507847812,
      "user": 0.25797758000000004,
      "system": 0.5735662,
      "min": 0.29556340962000005,
      "max": 0.33707094562
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.774 ± 0.148 1.663 2.085 5.27 ± 0.58
pacquet@main 1.798 ± 0.096 1.707 2.009 5.34 ± 0.48
pnpr@HEAD 0.336 ± 0.025 0.302 0.367 1.00
pnpr@main 0.384 ± 0.041 0.327 0.469 1.14 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7735657961600002,
      "stddev": 0.14842564400241778,
      "median": 1.70730754556,
      "user": 1.1713050199999997,
      "system": 1.12272868,
      "min": 1.66270648256,
      "max": 2.08539243956
    },
    {
      "command": "pacquet@main",
      "mean": 1.79780644896,
      "stddev": 0.09649374359392131,
      "median": 1.76703760006,
      "user": 1.22729772,
      "system": 1.1820672799999998,
      "min": 1.70687651456,
      "max": 2.00940306756
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33643650926,
      "stddev": 0.024514917101107193,
      "median": 0.33879683656000004,
      "user": 0.26535102000000005,
      "system": 0.6352451799999999,
      "min": 0.30210819956,
      "max": 0.36699243656
    },
    {
      "command": "pnpr@main",
      "mean": 0.38440975976,
      "stddev": 0.040618819442760495,
      "median": 0.38166363756,
      "user": 0.34078712,
      "system": 0.6598088799999999,
      "min": 0.32693864356,
      "max": 0.46904002256
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 429.1 ± 57.8 355.3 544.3 3.64 ± 0.57
pacquet@main 391.4 ± 31.1 361.4 465.7 3.32 ± 0.37
pnpr@HEAD 117.7 ± 9.3 102.7 134.3 1.00
pnpr@main 118.9 ± 9.5 102.7 134.9 1.01 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.42906787434,
      "stddev": 0.05782462765637326,
      "median": 0.43486437114,
      "user": 0.4412412,
      "system": 0.15516977999999998,
      "min": 0.35528343264,
      "max": 0.5443332186400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.39139977504,
      "stddev": 0.031058893779597575,
      "median": 0.38229477164000003,
      "user": 0.41609949999999996,
      "system": 0.13502108,
      "min": 0.36142463164,
      "max": 0.46571942364
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11772168344952384,
      "stddev": 0.00929461470874168,
      "median": 0.11791196664,
      "user": 0.05356844285714286,
      "system": 0.021628622857142857,
      "min": 0.10272668464000001,
      "max": 0.13427466964
    },
    {
      "command": "pnpr@main",
      "mean": 0.11893751482181819,
      "stddev": 0.009525790698308337,
      "median": 0.11894739064000001,
      "user": 0.0522878,
      "system": 0.023311389090909088,
      "min": 0.10272975964000002,
      "max": 0.13489902164
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 736.9 ± 48.0 666.8 830.2 1.00
pacquet@main 786.2 ± 77.6 665.2 925.6 1.07 ± 0.13
pnpm@HEAD 3844.8 ± 169.8 3577.2 4137.6 5.22 ± 0.41
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.7368785980533333,
      "stddev": 0.047980265530710595,
      "median": 0.73737259472,
      "user": 0.776706011111111,
      "system": 0.17142406666666665,
      "min": 0.66675426272,
      "max": 0.8302300737200001
    },
    {
      "command": "pacquet@main",
      "mean": 0.7861535430533334,
      "stddev": 0.07755387695573013,
      "median": 0.78049913672,
      "user": 0.8091812333333332,
      "system": 0.1789302888888889,
      "min": 0.66524479272,
      "max": 0.9256299827200001
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.844772072164444,
      "stddev": 0.16976591965791418,
      "median": 3.8371329997199997,
      "user": 6.02873401111111,
      "system": 0.28089506666666664,
      "min": 3.5771786287199996,
      "max": 4.13764805072
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 243.1 ± 25.8 216.4 284.8 1.00
pacquet@main 253.1 ± 43.1 214.1 353.4 1.04 ± 0.21
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24312619031000005,
      "stddev": 0.02582121066194975,
      "median": 0.23392394256000001,
      "user": 0.18428892666666663,
      "system": 0.12276495333333333,
      "min": 0.21637360806000003,
      "max": 0.28479544406
    },
    {
      "command": "pacquet@main",
      "mean": 0.2531014554236364,
      "stddev": 0.043122307321372046,
      "median": 0.24312493406000002,
      "user": 0.19806803272727275,
      "system": 0.1152565290909091,
      "min": 0.21406088906,
      "max": 0.35339148006
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 5.026 ± 0.413 4.629 5.944 1.38 ± 0.13
pacquet@main 5.260 ± 0.485 4.760 6.355 1.45 ± 0.15
pnpr@HEAD 3.630 ± 0.162 3.439 3.923 1.00
pnpr@main 3.661 ± 0.203 3.450 4.041 1.01 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 5.02617749764,
      "stddev": 0.4128671080033859,
      "median": 4.94136074724,
      "user": 2.60529832,
      "system": 2.20350616,
      "min": 4.62906771024,
      "max": 5.94448766024
    },
    {
      "command": "pacquet@main",
      "mean": 5.259883600340001,
      "stddev": 0.4854621795214033,
      "median": 5.121713035739999,
      "user": 3.0089235199999997,
      "system": 2.5055638599999996,
      "min": 4.75958825024,
      "max": 6.35519803924
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.6303625866399996,
      "stddev": 0.16203932199259102,
      "median": 3.56348580624,
      "user": 1.8465496199999998,
      "system": 1.83274526,
      "min": 3.43883303024,
      "max": 3.92347936324
    },
    {
      "command": "pnpr@main",
      "mean": 3.66059065094,
      "stddev": 0.20303068999716298,
      "median": 3.5799330622400003,
      "user": 1.8130501199999998,
      "system": 1.8129029600000002,
      "min": 3.44958602124,
      "max": 4.04114127924
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 143.9 ± 16.5 125.7 201.9 1.00
pacquet@main 185.6 ± 18.0 155.6 220.4 1.29 ± 0.19
pnpr@HEAD 188.3 ± 20.5 153.2 216.5 1.31 ± 0.21
pnpr@main 185.5 ± 29.4 142.6 227.1 1.29 ± 0.25
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.14394763463333332,
      "stddev": 0.01649643726059238,
      "median": 0.1413166928,
      "user": 0.17406840666666668,
      "system": 0.13919106666666667,
      "min": 0.1256751238,
      "max": 0.20188139580000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.18564876394285718,
      "stddev": 0.01799188248013204,
      "median": 0.18490333630000003,
      "user": 0.21565581142857143,
      "system": 0.18111032857142856,
      "min": 0.1556181818,
      "max": 0.2204327768
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.1883378957166667,
      "stddev": 0.020456117542201516,
      "median": 0.19014261780000002,
      "user": 0.20990990666666665,
      "system": 0.17172306666666667,
      "min": 0.1531622528,
      "max": 0.21653099680000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.18547835637142862,
      "stddev": 0.029362377845692168,
      "median": 0.18720796480000002,
      "user": 0.21557616857142853,
      "system": 0.15194839999999998,
      "min": 0.14257260980000003,
      "max": 0.22714524680000003
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review September 23, 2026 21:10
@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; the previous release-note issue is resolved and no new actionable defects remain.

Reviews (3) · Last reviewed commit: "Update .changeset/workspace-user-agent-e..."

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Protect project userAgent from environment-variable expansion

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Prevent project user-agent placeholders from exposing installer environment values to selected
 registries.
• Preserve expansion for trusted sources and retain literal project user-agent values.
• Align v11 TypeScript and v12 Rust behavior with regression coverage.
Diagram

graph TD
  A["Config Source"] --> B{"Trusted source?"}
  B -->|"Trusted"| C["Expand userAgent"] --> G["Request Header"]
  B -->|"Repository"| D{"Has placeholder?"}
  D -->|"Yes"| E["Drop userAgent"]
  D -->|"No"| F["Keep literal"] --> G
Loading
High-Level Assessment

The PR uses the existing request-setting trust gates in both supported configuration stacks, which is the safest and least disruptive approach. Disabling all user-agent expansion would break trusted configurations, while header sanitization would not reliably prevent arbitrary environment-value disclosure.

Files changed (5) +80 / -17

Bug fix (2) +24 / -14
env.rsGate Rust user-agent substitution by configuration trust +16/-12

Gate Rust user-agent substitution by configuration trust

• Moves 'user_agent' substitution from ordinary scalars into trusted request settings. Untrusted workspace configuration now drops user-agent values containing environment placeholders alongside registry, proxy, and pnpr server settings.

pnpm/crates/config/src/workspace_yaml/env.rs

getOptionsFromRootManifest.tsProtect v11 project user agents with the request-setting gate +8/-2

Protect v11 project user agents with the request-setting gate

• Renames the request-destination scalar set to reflect its broader responsibility and adds 'userAgent'. Repository-controlled placeholders are skipped while trusted-source expansion remains available.

pnpm11/config/reader/src/getOptionsFromRootManifest.ts

Tests (2) +49 / -3
workspace_settings.rsTest trusted and untrusted Rust user-agent handling +26/-3

Test trusted and untrusted Rust user-agent handling

• Adds regression coverage proving untrusted placeholders are dropped, trusted placeholders expand, and literal workspace user agents remain unchanged. Removes 'userAgent' from the ordinary scalar-expansion test.

pnpm/crates/config/src/workspace_yaml/tests/workspace_settings.rs

getOptionsFromRootManifest.test.tsCover v11 user-agent trust-boundary behavior +23/-0

Cover v11 user-agent trust-boundary behavior

• Tests that project placeholders are ignored, literal user agents are retained, and trusted user-agent placeholders are expanded.

pnpm11/config/reader/test/getOptionsFromRootManifest.test.ts

Documentation (1) +7 / -0
workspace-user-agent-env.mdDocument the user-agent environment expansion security fix +7/-0

Document the user-agent environment expansion security fix

• Adds patch release notes for '@pnpm/config.reader', 'pnpm', and 'pacquet'. Explains that project-level user agents containing placeholders are now ignored to prevent secret disclosure.

.changeset/workspace-user-agent-env.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Release note hedges the old behavior ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
The changeset describes the prior secret disclosure with the speculative phrase could send instead
of stating the condition and result directly. When the matching environment variable contains a
secret, the old behavior can be described definitively without weakening the security impact
conveyed to release-note readers.
Code

.changeset/workspace-user-agent-env.md[7]

+pnpm no longer expands environment variables in a `userAgent` set in a project's `pnpm-workspace.yaml`. A placeholder there could send a secret from the installer's environment to a registry chosen by the same file. A `userAgent` with a placeholder in that file is now ignored [#15415](https://github.com/pnpm/pnpm/issues/15415).
Relevance

●●● Strong

Recent changeset reviews accept direct, precise observable wording and remove hedged or unclear
release-note phrasing.

PR-#15408
PR-#15372

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 3058322 prohibits hedging terms such as could when they replace a definite
observable outcome. The added changeset uses could send for the prior secret-disclosure behavior.

Rule 3058322: Changeset entries must describe observable behavior changes only
.changeset/workspace-user-agent-env.md[7-7]

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 uses `could send` to hedge the previous behavior, while changeset entries must state observable behavior directly and without speculative wording.

## Fix Focus Areas
- .changeset/workspace-user-agent-env.md[7-7]

## Recommended Fix
Rewrite the old-behavior sentence as a definite, past-tense statement with its condition made explicit, such as: `Previously, when a matching environment variable contained a secret, pnpm sent its value to a registry chosen by the workspace file.`

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



Informational

2. Users get wrong expansion guidance 🔗 Cross-repo conflict ≡ Correctness
Description
substitute_env_untrusted now removes a project-level userAgent containing an environment
placeholder, while pnpm.io’s current and v11 settings pages describe configuration values as
expandable and enumerate only registry URL exceptions. Anyone templating userAgent in a project
workspace may follow that guidance, but pnpm 11 and 12 will ignore the setting instead of producing
the documented request header.
Code

pnpm/crates/config/src/workspace_yaml/env.rs[54]

+            &mut self.user_agent,
Relevance

● Weak

A same-PR precedent explicitly rejected preventing userAgent filtering; repository behavior
intentionally distinguishes trusted and untrusted sources.

PR-#15392
PR-#13158

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds user_agent to the untrusted scalar filter, whereas both pnpm.io settings pages state
that configuration values support placeholders and identify only registry URL settings as
exceptions. These sources therefore expose contradictory behavior for the same public configuration
contract.

pnpm/crates/config/src/workspace_yaml/env.rs[49-57]
pnpm/crates/config/src/workspace_yaml/tests/workspace_settings.rs[143-166]
External repo: pnpm/pnpm.io, docs/settings.md [24-35]
External repo: pnpm/pnpm.io, versioned_docs/version-11.x/settings.md [27-35]

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 pnpm 11 and current pnpm.io settings documentation says configuration values support environment expansion and lists only registry URLs as exceptions, but this change also ignores project-level `userAgent` values containing placeholders.

## Fix Focus Areas
- pnpm/crates/config/src/workspace_yaml/env.rs[49-57]
- pnpm.io/docs/settings.md[24-35]
- pnpm.io/versioned_docs/version-11.x/settings.md[27-35]

## Recommended Fix
Coordinate a pnpm.io update that adds `userAgent` to the environment-expansion warning in both the current and versioned v11 settings pages. Explain that placeholders are ignored only when the setting comes from a project-level `pnpm-workspace.yaml`, while trusted global, environment, and command-line sources continue to expand them.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Skills: review-code
Review mode: ⏭️ Skipped: The latest push only revises wording in a changeset release-note markdown file and has no behavioral or runtime effect.

Grey Divider

Tip of the day
💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper

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.

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

zkochan commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Qodo findings:

  1. Release-note hedge: fixed in 992cc61. The old behavior is now stated directly.
  2. pnpm.io guidance: this is real, but it lives in pnpm/pnpm.io, so this PR doesn't change it. The settings pages there should list userAgent next to the registry URL exceptions as a value whose placeholders a project file does not expand. I've left that to the maintainer as a follow-up in that repository.

Written by an agent (Claude Code, claude-opus-5-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 992cc61

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

Comment thread .changeset/workspace-user-agent-env.md Resolved
greptile-apps[bot]
greptile-apps Bot previously approved these changes Sep 23, 2026
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@greptile-apps
greptile-apps Bot dismissed their stale review September 23, 2026 21:47

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

@qodo-code-review

Copy link
Copy Markdown

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

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

u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
…m#15419)

A `userAgent` in a repository's pnpm-workspace.yaml had its `${VAR}`
placeholders resolved and sent as the User-Agent header to the registry,
which the same file can choose with a literal `registry:`. That let a
repository deliver an installer's environment variable (a token, say) to
a host it names, without any lifecycle script.

`userAgent` now joins the request settings whose placeholders are dropped
when the file is repository-controlled: `REQUEST_SCALAR_KEYS` in v11, and
the filtered scalars of `substitute_env_untrusted` in v12. Trusted sources
(the global config and the environment overlay) still expand it.

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

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repository-controlled userAgent resolves environment variables into an outbound request header

2 participants