Skip to content

fix(dist-tag): support npm's web-based 2FA flow - #11998

Merged
zkochan merged 2 commits into
mainfrom
fix-dist-tag
May 28, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-dist-tag

Conversation

@zkochan

@zkochan zkochan commented May 27, 2026 •

Copy link
Copy Markdown
Member

Summary

pnpm dist-tag add (and rm) without --otp fails against npmjs.org with:

[ERR_PNPM_UNAUTHORIZED] You must be logged in to set dist-tag "latest-10" on packages.
"You must provide a one-time pass. Upgrade your client to npm@latest in order to use 2FA."

The browser never opens — pnpm just surfaces the legacy 401 as UNAUTHORIZED and exits.

pn dist-tag add … --otp=<6-digit code> already works; the gap is the interactive path that npm CLI handles via web 2FA. The "Upgrade your client" hint in the 401 body is the registry's polite way of saying "you didn't send npm-auth-type: web, so I'm falling back to the legacy challenge."

What changed

  • @pnpm/registry-access.client#setDistTag: now sends npm-auth-type: web (matching npm CLI's auth-type default) when no --otp is given, and npm-auth-type: legacy + npm-otp when --otp is given. On 401, the body is parsed: a JSON shape with authUrl/doneUrl, or a body matching /one-time pass/i, is converted to a SyntheticOtpError; anything else still throws UNAUTHORIZED.
  • @pnpm/registry-access.commands#distTag: wraps both add and rm in the existing @pnpm/network.web-auth#withOtpHandling (the same helper that backs pnpm publish's web 2FA), so the EOTP-shaped error opens the browser, polls the done URL, and retries with the 64-char token as npm-otp (with npm-auth-type: web still present, so the session is recognized).
  • DELETE path: the inline DELETE in distTag.ts was extracted into deleteDistTag and gets the same headers + OTP handling.
  • Drive-by @pnpm/network.fetch cleanup: the abbreviated-metadata Accept header (application/vnd.npm.install-v1+json; q=1.0, …) is only emitted on GET/HEAD now; sending it on writes is non-standard (npm-registry-fetch never does so) and was a distraction during debugging.

Test plan

  • All 86 dist-tag tests pass (@pnpm/registry-access.commands).
  • 6 new unit tests covering the OTP behavior in registry-access/commands/test/setDistTag.ts:
    • npm-auth-type: web on the initial request when no OTP
    • Web flow retry keeps npm-auth-type: web and adds npm-otp (caught a real bug in an earlier iteration of the patch)
    • --otp switches to authType: legacy
    • 401 with {authUrl, doneUrl} body → SyntheticOtpError(body)
    • 401 mentioning "one-time pass" → SyntheticOtpError(undefined)
    • 401 with no OTP marker → UNAUTHORIZED PnpmError
  • 2 new tests in @pnpm/network.fetch lock the Accept-header behavior (sent on GET, omitted on PUT).
  • Manually verified end-to-end against npmjs.org: with no --otp the browser opens, web auth completes, and the dist-tag is set.

Notes / follow-ups

  • unpublish, owner add/rm, deprecate/undeprecate (in registry-access/commands) have the same shape (inline npm-otp header, no withOtpHandling) and presumably break the same way for non---otp users. Out of scope here but worth a follow-up.
  • Changeset bumps @pnpm/registry-access.client as minor because SetDistTagOptions gained an authType field; the rest is patch.

Draft because I'd like a sanity check on putting OTP plumbing at the command-handler layer (vs. inside setDistTag itself). I went that way to keep @pnpm/registry-access.client UI-free, mirroring how publishWithOtpHandling lives in @pnpm/releasing.commands rather than in libnpmpublish.


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

Summary by CodeRabbit

  • New Features
    • Browser-based two-factor auth for dist-tag commands: pnpm dist-tag add and pnpm dist-tag rm now surface registry OTP challenges in the browser flow; legacy --otp=<code> still works.
  • Bug Fixes
    • Dist-tag write requests now include the appropriate auth type so OTP challenges are correctly handled and retried.
  • Tests
    • Added tests covering OTP/web-auth behaviors and request header handling.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2cb77daa-dd56-4c04-b0cc-8f5a92535941

📥 Commits

Reviewing files that changed from the base of the PR and between 83c4122 and cde9de6.

📒 Files selected for processing (2)
  • registry-access/client/src/setDistTag.ts
  • registry-access/commands/src/distTag.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • registry-access/client/src/setDistTag.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run benchmark on ubuntu-latest
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Compile & Lint
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Follow Standard Style with trailing commas, preferring functions over classes, and declaring functions after they are used (relying on hoisting)
Use a single options object instead of multiple parameters when a function needs more than two or three arguments
Follow Import Order: Standard libraries first, then external dependencies (alphabetically), then relative imports
Write self-documenting code where function names, parameters, and types explain what a function does without requiring prose comments
Do not write comments that restate what the code already says; refactor via renaming, splitting helpers, or restructuring instead
Do not repeat documentation at call sites that already exists in JSDoc on the callee; update JSDoc once for all call sites to benefit
Use JSDoc only for a function's contract (preconditions, postconditions, edge cases, why the function exists), not for re-narrating the body
Do not record past implementation shape, refactor history, or 'the previous code did X' framing in code; use git log and git blame instead
Write comments only when: the reason for code is non-obvious (hidden invariant, workaround for known bug, deliberate exception), or the right name doesn't fit (temporary technical constraint)

Files:

  • registry-access/commands/src/distTag.ts
🧠 Learnings (1)
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • registry-access/commands/src/distTag.ts
🔇 Additional comments (1)
registry-access/commands/src/distTag.ts (1)

156-169: LGTM!

Also applies to: 203-214, 248-249, 257-273, 315-329


📝 Walkthrough

Walkthrough

Adds npm web-based 2FA support to pnpm dist-tag add/rm, conditions the metadata Accept header on HTTP method, extends setDistTag with authType/otp, routes commands through withOtpHandling, and adds tests and project references/dependencies.

Changes

Web-based OTP support for dist-tag commands

Layer / File(s) Summary
HTTP Accept header method-awareness
network/fetch/src/fetchFromRegistry.ts, network/fetch/test/fetchFromRegistry.test.ts
The Accept header for npm metadata is now conditionally set only on read methods (GET/HEAD), removed from write requests to align with npm registry expectations.
SetDistTag API with OTP and auth-type support
registry-access/client/src/setDistTag.ts
SetDistTag options now accept authType and otp fields; the function includes npm-auth-type and npm-otp headers when provided, and 401 responses are parsed by a new parseAuthError/tryParseJson helper to extract authUrl/doneUrl or detect OTP challenge phrases.
DistTag commands refactored for OTP handling
registry-access/commands/src/distTag.ts
Both add and rm commands derive authType and route through withOtpHandling; add forwards otp and authType to setDistTag, while rm uses a new deleteDistTag helper. Both establish shared OTP context and WEB_AUTH_FETCH_OPTIONS for OTP flow orchestration.
SetDistTag test coverage
registry-access/commands/test/setDistTag.ts
New test suite validating request headers for web and legacy auth modes with/without OTP, and verifying 401 error handling: authUrl/doneUrl extraction, one-time-pass phrase detection, and unauthorized fallback.
Dependencies and project configuration
registry-access/client/package.json, registry-access/client/tsconfig.json, registry-access/commands/package.json, registry-access/commands/tsconfig.json, .changeset/fix-dist-tag-web-otp.md
Adds @pnpm/network.web-auth dependency to client and commands packages, adds TypeScript project references for web-auth and logger modules, and documents the dist-tag OTP fix and version bumps in the changeset.

Sequence Diagram

sequenceDiagram
  participant CLI
  participant DistTagCmd as dist-tag command
  participant WithOtp as withOtpHandling
  participant RegistryOp as setDistTag/deleteDistTag
  participant Npm as npm Registry
  participant Browser as Browser web-auth

  CLI->>DistTagCmd: invoke add/rm (opts, cliOtp)
  DistTagCmd->>DistTagCmd: compute authType (web|legacy) and otp
  DistTagCmd->>WithOtp: run operation with OTP context
  WithOtp->>RegistryOp: call with authType and otp
  RegistryOp->>Npm: PUT/DELETE with npm-auth-type and optional npm-otp
  alt Npm responds 401 with authUrl/doneUrl or OTP challenge
    Npm-->>RegistryOp: 401 + auth info
    RegistryOp-->>WithOtp: throw SyntheticOtpError
    WithOtp->>Browser: open authUrl and poll doneUrl
    Browser-->>WithOtp: auth completed (done)
    WithOtp->>RegistryOp: retry operation with obtained OTP
  else success
    Npm-->>RegistryOp: 2xx
    RegistryOp-->>CLI: success
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • pnpm/pnpm#11863: Intersects on the registry request layer—both PRs affect fetchFromRegistry behavior; the stage command PR reuses the HTTP fetch for its approve/reject calls, which will inherit the method-gated Accept header logic from this PR.

Poem

🐰 I hopped where headers meet the net,

npm-web whispers, "Try the web,"
Dist-tags pause for a browser wink,
OTP flows, a gentle link,
Hooray — the rabbit bounds, secure and kept.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(dist-tag): support npm's web-based 2FA flow' directly and clearly describes the main change: enabling web-based 2FA (two-factor authentication) flow for dist-tag operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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-dist-tag

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 and usage tips.

@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.160 ± 0.180 2.009 2.564 1.06 ± 0.09
pacquet@main 2.043 ± 0.039 2.004 2.108 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.1604119650399998,
      "stddev": 0.180379683247681,
      "median": 2.10819464054,
      "user": 2.6379070199999997,
      "system": 3.3754229199999997,
      "min": 2.00903836254,
      "max": 2.56435988054,
      "times": [
        2.16419551354,
        2.0203801065399998,
        2.13338925154,
        2.02846215654,
        2.00903836254,
        2.08646148254,
        2.39483290254,
        2.56435988054,
        2.07307219554,
        2.12992779854
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.04344071554,
      "stddev": 0.039419805168550384,
      "median": 2.0301689760399997,
      "user": 2.6375878200000002,
      "system": 3.3451206200000003,
      "min": 2.00371086554,
      "max": 2.10762061954,
      "times": [
        2.1064190315399998,
        2.06737519254,
        2.03290548654,
        2.10762061954,
        2.01689451054,
        2.05607034254,
        2.02743246554,
        2.00665245654,
        2.00371086554,
        2.00932618454
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 656.8 ± 38.8 622.1 763.0 1.00
pacquet@main 665.3 ± 39.5 638.3 748.7 1.01 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6568242944800001,
      "stddev": 0.038787133011907324,
      "median": 0.64677296888,
      "user": 0.35218984,
      "system": 1.3202504199999998,
      "min": 0.6220996963800001,
      "max": 0.76295299738,
      "times": [
        0.76295299738,
        0.64589342738,
        0.65357327838,
        0.65895845338,
        0.64310892538,
        0.64765251038,
        0.63863605438,
        0.6220996963800001,
        0.63856991038,
        0.65679769138
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6652962310799999,
      "stddev": 0.039483556692675094,
      "median": 0.64486317538,
      "user": 0.34071473999999996,
      "system": 1.32085232,
      "min": 0.63834576038,
      "max": 0.74866362138,
      "times": [
        0.74866362138,
        0.65065335638,
        0.6406892333800001,
        0.64202240838,
        0.63834576038,
        0.64660683138,
        0.63935494238,
        0.64311951938,
        0.68150197938,
        0.72200465838
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.255 ± 0.027 2.209 2.299 1.00
pacquet@main 2.278 ± 0.028 2.222 2.310 1.01 ± 0.02
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.2545386497599997,
      "stddev": 0.0271237980603259,
      "median": 2.25507923336,
      "user": 3.7110421199999997,
      "system": 3.0544915799999997,
      "min": 2.20938126286,
      "max": 2.29927830886,
      "times": [
        2.25625867286,
        2.2756155758600003,
        2.2825764418600003,
        2.2289776308600002,
        2.26126298386,
        2.29927830886,
        2.20938126286,
        2.25389979386,
        2.22986231286,
        2.24827351386
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.2783925786599997,
      "stddev": 0.027680334678612122,
      "median": 2.2823882168600003,
      "user": 3.71959242,
      "system": 3.06144538,
      "min": 2.22230417386,
      "max": 2.30958238986,
      "times": [
        2.24295934086,
        2.30958238986,
        2.3071384798600003,
        2.27345562486,
        2.27728702386,
        2.22230417386,
        2.28805356786,
        2.28748940986,
        2.30038815786,
        2.27526761786
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.408 ± 0.019 1.386 1.450 1.00
pacquet@main 1.426 ± 0.065 1.373 1.603 1.01 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4078776357400002,
      "stddev": 0.01889691285468865,
      "median": 1.40345171774,
      "user": 1.64338944,
      "system": 1.7257114000000002,
      "min": 1.3858516247400001,
      "max": 1.4504265817400002,
      "times": [
        1.39583013874,
        1.39712392574,
        1.4221330037400002,
        1.4028434627400002,
        1.4078913157400001,
        1.40405997274,
        1.3920001647400002,
        1.4206161667400001,
        1.4504265817400002,
        1.3858516247400001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.42569461614,
      "stddev": 0.06450344552352857,
      "median": 1.40885760924,
      "user": 1.63541424,
      "system": 1.7491349,
      "min": 1.3733597617400002,
      "max": 1.60276663274,
      "times": [
        1.4000375397400002,
        1.4207474247400003,
        1.4229069467400002,
        1.3733597617400002,
        1.60276663274,
        1.4012505247400002,
        1.4308237917400002,
        1.38733832074,
        1.4092356917400002,
        1.40847952674
      ]
    }
  ]
}

@github-actions

github-actions Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/11998
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,254.54 ms
(-4.96%)Baseline: 2,372.19 ms
2,846.63 ms
(79.20%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,407.88 ms
(-5.85%)Baseline: 1,495.42 ms
1,794.51 ms
(78.45%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,160.41 ms
(+4.47%)Baseline: 2,068.00 ms
2,481.60 ms
(87.06%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
656.82 ms
(-3.46%)Baseline: 680.35 ms
816.43 ms
(80.45%)
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan marked this pull request as ready for review May 28, 2026 00:33
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Support npm's web-based 2FA flow for dist-tag operations
🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Support npm's web-based 2FA flow for dist-tag add/rm commands
• Send npm-auth-type: web header and handle web auth challenges
• Extract deleteDistTag function with OTP handling wrapper
• Fix Accept header to only apply to GET/HEAD requests
Diagram
flowchart LR
  A["dist-tag add/rm CLI"] -->|no --otp| B["Send npm-auth-type: web"]
  A -->|with --otp| C["Send npm-auth-type: legacy + npm-otp"]
  B -->|401 with authUrl| D["SyntheticOtpError"]
  C -->|401 with authUrl| D
  D -->|withOtpHandling| E["Open browser auth"]
  E -->|Poll doneUrl| F["Get 64-char token"]
  F -->|Retry with npm-otp| G["Success"]
  H["Accept header cleanup"] -->|GET/HEAD only| I["Avoid 400 on writes"]

Loading

Grey Divider

File Changes

1. network/fetch/src/fetchFromRegistry.ts 🐞 Bug fix +9/-3

Conditionally apply Accept header based on HTTP method

network/fetch/src/fetchFromRegistry.ts


2. network/fetch/test/fetchFromRegistry.test.ts 🧪 Tests +46/-0

Add tests for Accept header on write vs read requests

network/fetch/test/fetchFromRegistry.test.ts


3. registry-access/client/src/setDistTag.ts ✨ Enhancement +34/-2

Add web auth type and OTP error handling for dist-tag

registry-access/client/src/setDistTag.ts


View more (8)
4. registry-access/commands/src/distTag.ts ✨ Enhancement +103/-23

Wrap dist-tag operations with web auth flow handling

registry-access/commands/src/distTag.ts


5. registry-access/commands/test/setDistTag.ts 🧪 Tests +150/-0

Add comprehensive tests for OTP and auth type behavior

registry-access/commands/test/setDistTag.ts


6. .changeset/fix-dist-tag-web-otp.md 📝 Documentation +10/-0

Document fix for dist-tag web 2FA support

.changeset/fix-dist-tag-web-otp.md


7. pnpm-lock.yaml Dependencies +12/-0

Update dependencies for web-auth and enquirer

pnpm-lock.yaml


8. registry-access/client/package.json Dependencies +1/-0

Add web-auth dependency to client package

registry-access/client/package.json


9. registry-access/client/tsconfig.json ⚙️ Configuration changes +3/-0

Add web-auth to TypeScript references

registry-access/client/tsconfig.json


10. registry-access/commands/package.json Dependencies +6/-0

Add web-auth and enquirer dependencies to commands

registry-access/commands/package.json


11. registry-access/commands/tsconfig.json ⚙️ Configuration changes +6/-0

Add logger and web-auth to TypeScript references

registry-access/commands/tsconfig.json


Grey Divider

Qodo Logo

Without `--otp`, `pnpm dist-tag add` (and `rm`) failed against
npmjs.org with `[ERR_PNPM_UNAUTHORIZED] You must be logged in to set
dist-tag … "You must provide a one-time pass. Upgrade your client to
npm@latest in order to use 2FA."` — the browser never opened. The
fallback "upgrade your client" message is what npmjs.org returns when
the client doesn't announce `npm-auth-type: web`; without that header
the server skips the web challenge and tells the user to install a
newer npm. `--otp=<6-digit code>` already worked because the OTP went
out in `npm-otp` directly.

Send `npm-auth-type: web` on dist-tag writes when no `--otp` is
given, surface 401 responses carrying `authUrl`/`doneUrl` (or the
legacy "one-time pass" text) as `SyntheticOtpError`, and wrap the
call in the existing `withOtpHandling` helper (already used by
`pnpm publish`), which opens the browser, polls the done URL, and
retries with the resulting token as `npm-otp` while keeping
`npm-auth-type: web` in place.

Drive-by cleanup in `@pnpm/network.fetch`: the abbreviated-metadata
`Accept` header is no longer attached to non-GET requests, matching
`npm-registry-fetch`'s behavior.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@registry-access/client/src/setDistTag.ts`:
- Around line 15-21: The code documents authType defaulting to 'web' but only
sends the npm-auth-type header when callers explicitly pass authType; update the
header construction in setDistTag (where headers are built for the request) to
treat undefined authType as 'web' and always send npm-auth-type:
<authTypeValue>, using the authType parameter (defaulting to 'web') so callers
relying on the exported default trigger the web OTP flow; ensure the same change
is applied to the other header-construction site mentioned (lines ~30-33).
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: db58d3fd-ce81-4c91-9285-c04e35e868d9

📥 Commits

Reviewing files that changed from the base of the PR and between 72d997c and dd3f0d9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • .changeset/fix-dist-tag-web-otp.md
  • network/fetch/src/fetchFromRegistry.ts
  • network/fetch/test/fetchFromRegistry.test.ts
  • registry-access/client/package.json
  • registry-access/client/src/setDistTag.ts
  • registry-access/client/tsconfig.json
  • registry-access/commands/package.json
  • registry-access/commands/src/distTag.ts
  • registry-access/commands/test/setDistTag.ts
  • registry-access/commands/tsconfig.json
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Follow Standard Style with trailing commas, preferring functions over classes, and declaring functions after they are used (relying on hoisting)
Use a single options object instead of multiple parameters when a function needs more than two or three arguments
Follow Import Order: Standard libraries first, then external dependencies (alphabetically), then relative imports
Write self-documenting code where function names, parameters, and types explain what a function does without requiring prose comments
Do not write comments that restate what the code already says; refactor via renaming, splitting helpers, or restructuring instead
Do not repeat documentation at call sites that already exists in JSDoc on the callee; update JSDoc once for all call sites to benefit
Use JSDoc only for a function's contract (preconditions, postconditions, edge cases, why the function exists), not for re-narrating the body
Do not record past implementation shape, refactor history, or 'the previous code did X' framing in code; use git log and git blame instead
Write comments only when: the reason for code is non-obvious (hidden invariant, workaround for known bug, deliberate exception), or the right name doesn't fit (temporary technical constraint)

Files:

  • network/fetch/test/fetchFromRegistry.test.ts
  • registry-access/commands/test/setDistTag.ts
  • registry-access/client/src/setDistTag.ts
  • network/fetch/src/fetchFromRegistry.ts
  • registry-access/commands/src/distTag.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use util.types.isNativeError() instead of instanceof Error for error type checking in Jest tests

Files:

  • network/fetch/test/fetchFromRegistry.test.ts
🧠 Learnings (3)
📚 Learning: 2026-05-26T21:01:06.666Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11966
File: .changeset/require-tarball-integrity.md:6-6
Timestamp: 2026-05-26T21:01:06.666Z
Learning: In pnpm lockfile-related release notes/docs (especially changeset markdown), preserve URL hostnames exactly as they appear in pnpm-lock.yaml tarball resolution entries—keep hosts like `codeload.github.com`, `bitbucket.org`, and `gitlab.com` in lowercase. Do not “correct” them to title-case/preserve brand capitalization (e.g., LanguageTool rules like `GITHUB` capitalization) because these are literal URL fragments, not platform brand names.

Applied to files:

  • .changeset/fix-dist-tag-web-otp.md
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • network/fetch/test/fetchFromRegistry.test.ts
  • registry-access/commands/test/setDistTag.ts
  • registry-access/client/src/setDistTag.ts
  • network/fetch/src/fetchFromRegistry.ts
  • registry-access/commands/src/distTag.ts
📚 Learning: 2026-05-05T23:03:04.286Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11479
File: __utils__/scripts/package.json:6-9
Timestamp: 2026-05-05T23:03:04.286Z
Learning: The pattern cross-env NODE_OPTIONS="$NODE_OPTIONS ..." in package.json scripts is an established convention in the pnpm/pnpm repository and is used across many packages (e.g., fs/hard-link-dir, worker, __utils__/scripts). Do not flag this as a cross-platform issue in individual files; if a change is needed, apply it as a repo-wide change in a separate PR. Scope this guidance to all package.json files in the repo; use the minimatch pattern '**/package.json' to identify relevant files and review changes at the repository level rather than per-file.

Applied to files:

  • registry-access/client/package.json
  • registry-access/commands/package.json
🔇 Additional comments (7)
.changeset/fix-dist-tag-web-otp.md (1)

1-11: LGTM!

registry-access/client/package.json (1)

36-36: LGTM!

registry-access/client/tsconfig.json (1)

17-20: LGTM!

registry-access/commands/package.json (1)

41-42: LGTM!

Also applies to: 47-47, 52-54, 57-57

registry-access/commands/tsconfig.json (1)

27-29: LGTM!

Also applies to: 39-41

network/fetch/src/fetchFromRegistry.ts (1)

68-73: LGTM!

Also applies to: 128-147

network/fetch/test/fetchFromRegistry.test.ts (1)

314-358: LGTM!

Comment thread registry-access/commands/src/distTag.ts Resolved
…TP context

Two review fixes:

- `setDistTag` documented `authType` as defaulting to `'web'` but only
  sent the `npm-auth-type` header when the field was explicitly passed.
  Always send the header, defaulting to `'web'`.

- `OTP_CONTEXT` used a module-level `createFetchFromRegistry({})`, so
  the `withOtpHandling` doneUrl poll ignored the command's proxy / TLS
  / `configByUri` config. Build the OTP context per call from the
  command's `opts` instead.

Also rename `toOtpOrUnauthorizedError` → `parseAuthError` and drop the
spurious `async` (the body string is already awaited at the call site).
@zkochan
zkochan merged commit b1fa2d5 into main May 28, 2026
15 checks passed
@zkochan
zkochan deleted the fix-dist-tag branch May 28, 2026 10:24
@coderabbitai coderabbitai Bot mentioned this pull request May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant