Skip to content

Expose web authentication authUrl and doneUrl in JSON error output when OTP is required in a non-interactive terminal - #12786

Merged
zkochan merged 5 commits into
pnpm:mainfrom
Andarist:expose-non-tty-web-auth-urls
Jul 3, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
Andarist:expose-non-tty-web-auth-urls

Conversation

@Andarist

@Andarist Andarist commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Expose web-auth OTP challenge URLs in --json error output when pnpm is running non-interactively.

When the registry returns authUrl and doneUrl, pnpm now preserves them on the non-interactive OTP error and includes them as error.authUrl and error.doneUrl in JSON output. This lets wrapper tools complete the web-auth flow.

This is a change equivalent to npm/cli#8952
closes #12724

Squash Commit Body

Preserve web-auth OTP challenge URLs when OTP handling fails because pnpm is not running in an interactive terminal.

The web-auth layer now carries authUrl and doneUrl from the registry challenge onto OtpNonInteractiveError. The pnpm error handler includes those fields in parseable JSON error output when present.

The same URL preservation was added to pacquet's web-auth error type to keep the two implementations aligned. Tests cover the TS and Rust web-auth layers and the pnpm JSON error output path.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ 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.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • When OTP is required in a non-interactive terminal, JSON error output now includes authUrl and doneUrl (as valid http/https URLs).
  • Bug Fixes
    • Credentials embedded in these URLs are removed; non-http/https values are omitted.
    • Web-auth URL handling now falls back to the classic OTP prompt when URL schemes aren’t http/https.
  • Tests
    • Added coverage for URL preservation/omission behavior and updated publish/HTTP-server scenarios.
  • Chores
    • Updated release configuration for the relevant web-auth packages.

@Andarist
Andarist requested a review from zkochan as a code owner July 3, 2026 11:59
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Expose web-auth authUrl/doneUrl in JSON OTP non-interactive errors

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Preserve registry web-auth URLs on OTP non-interactive errors.
• Include authUrl/doneUrl in pnpm --json error output for automation.
• Add TS/Rust tests covering URL propagation and JSON output.
Diagram

graph TD
  W["Wrapper tool"] --> P["pnpm CLI"] --> O["withOtpHandling"] --> E(("OtpNonInteractiveError\n+ URLs")) --> H["errorHandler"] --> J["--json error"] --> W
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Emit full OTP challenge body in JSON errors
  • ➕ Future-proof for additional registry fields without more plumbing
  • ➕ Avoids adding more top-level error properties
  • ➖ Risk of exposing unintended/sensitive fields
  • ➖ Less ergonomic contract than stable top-level keys
2. Standardize error-to-JSON serialization across pnpm errors
  • ➕ More consistent/maintainable structured output for all error metadata
  • ➕ Reduces future one-off extractors like getWebAuthUrls()
  • ➖ Larger refactor with higher compatibility/review risk
  • ➖ Not necessary for this narrowly-scoped fix

Recommendation: Proceed with the PR’s explicit approach: carry only authUrl/doneUrl on OtpNonInteractiveError and selectively include them in JSON output when present. This gives wrapper tools a stable, minimal contract while keeping the JSON surface area constrained, and it keeps the TS and pacquet Rust ports aligned.

Files changed (7) +161 / -5

Enhancement (1) +12 / -0
errorHandler.tsExpose web-auth URLs in pnpm JSON error payload +12/-0

Expose web-auth URLs in pnpm JSON error payload

• Extends parseable JSON error output to include authUrl/doneUrl when present on the thrown error. Adds getWebAuthUrls() to safely copy only string-valued URLs into the JSON payload.

pnpm11/pnpm/src/errorHandler.ts

Bug fix (2) +30 / -4
with_otp_handling.rsPreserve web-auth URLs on Rust OtpNonInteractiveError +19/-2

Preserve web-auth URLs on Rust OtpNonInteractiveError

• Changes OtpNonInteractiveError from a unit struct to a struct carrying optional auth_url/done_url and adds a constructor that extracts them from the OTP challenge body. Updates the non-interactive path to preserve challenge URLs instead of dropping them.

pacquet/crates/network-web-auth/src/with_otp_handling.rs

withOtpHandling.tsCarry authUrl/doneUrl on TS OtpNonInteractiveError +11/-2

Carry authUrl/doneUrl on TS OtpNonInteractiveError

• Passes the OTP error body into OtpNonInteractiveError when running in a non-interactive terminal. Extends OtpNonInteractiveError to store authUrl and doneUrl when present and string-typed.

pnpm11/network/web-auth/src/withOtpHandling.ts

Tests (3) +113 / -1
tests.rsTest Rust non-interactive error preserves auth/done URLs +21/-0

Test Rust non-interactive error preserves auth/done URLs

• Adds a Tokio test asserting that when stdin is non-TTY, the WithOtpError::NonInteractive error retains auth_url and done_url from the registry challenge body.

pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs

withOtpHandling.test.tsTest TS OtpNonInteractiveError includes web-auth URLs +20/-0

Test TS OtpNonInteractiveError includes web-auth URLs

• Adds a Jest test verifying that authUrl and doneUrl from an EOTP error body are preserved on OtpNonInteractiveError when stdin is not a TTY.

pnpm11/network/web-auth/test/withOtpHandling.test.ts

errorHandler.test.tsIntegration test for web-auth URLs in --json OTP errors +72/-1

Integration test for web-auth URLs in --json OTP errors

• Adds an HTTP server-backed test that triggers an OTP web-auth 401 response during 'dist-tag add' and asserts pnpm exits with code 1 and prints authUrl/doneUrl in JSON output.

pnpm11/pnpm/test/errorHandler.test.ts

Documentation (1) +6 / -0
webauth-json-urls.mdAdd changeset for web-auth URL JSON error output +6/-0

Add changeset for web-auth URL JSON error output

• Adds a patch changeset for @pnpm/network.web-auth and pnpm documenting that authUrl/doneUrl are now included in JSON error output for non-interactive OTP failures.

.changeset/webauth-json-urls.md

@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR propagates OTP authUrl/doneUrl through Rust and TypeScript web-auth errors, then includes those fields in pnpm’s JSON error output for non-interactive OTP failures. It also adds tests, package wiring, and a changeset.

Changes

OTP Non-Interactive Error URL Propagation

Layer / File(s) Summary
Rust OTP error carries URLs
pacquet/crates/network-web-auth/src/with_otp_handling.rs, pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs
OtpNonInteractiveError becomes a struct with optional auth_url/done_url, the constructor extracts canonical HTTP(S) URLs from the OTP body, and the non-interactive path passes the body through; tests cover preserved and rejected URL cases.
TypeScript OTP error carries URLs
pnpm11/network/web-auth/src/withOtpHandling.ts, pnpm11/network/web-auth/src/index.ts, pnpm11/network/web-auth/test/withOtpHandling.test.ts
OtpNonInteractiveError gains optional authUrl/doneUrl fields, the constructor canonicalizes them from an optional body, and withOtpHandling passes the original body into the error; tests cover preserved and rejected URL cases.
pnpm JSON error output includes web-auth URLs
pnpm11/pnpm/src/errorHandler.ts, pnpm11/pnpm/test/errorHandler.test.ts, pnpm11/pnpm/test/utils/execPnpm.ts, pnpm11/pnpm/test/utils/index.ts, pnpm11/pnpm/package.json, pnpm11/pnpm/tsconfig.json
errorHandler conditionally extracts authUrl/doneUrl for ERR_PNPM_OTP_NON_INTERACTIVE, spreads them into the unhandled-exception JSON payload, and an end-to-end test validates the output with a mock registry server.
Changeset entry
.changeset/webauth-json-urls.md
Adds a minor changeset for @pnpm/network.web-auth and pnpm documenting the JSON error output change.

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

Assessment against linked issues

Objective Addressed Explanation
Return 2FA auth information in ERR_PNPM_OTP_NON_INTERACTIVE [#12724] ✅

Possibly related issues

  • pnpm/pnpm#12721 — Touches the same network-web-auth OTP URL canonicalization and authUrl/doneUrl handling.

Possibly related PRs

  • pnpm/pnpm#11998 — Shares the same web-auth OTP flow and URL propagation path through withOtpHandling and related error shaping.

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

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 3, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Userinfo not redacted 🐞 Bug ⛨ Security
Description
The new JSON error output for ERR_PNPM_OTP_NON_INTERACTIVE copies authUrl/doneUrl after URL
parsing but does not strip URL userinfo (user:pass@), so credential-bearing URLs returned by a
registry/proxy can be echoed into parseable output and end up in CI/wrapper logs. pnpm already
treats URL-embedded credentials as sensitive elsewhere (via redactUrlCredentials), so this is an
inconsistent new leak surface.
Code

pnpm11/pnpm/src/errorHandler.ts[R84-105]

+function getWebAuthUrls (error: Error & { code?: string; authUrl?: unknown, doneUrl?: unknown }): { authUrl?: string, doneUrl?: string } | undefined {
+  if (error.code !== 'ERR_PNPM_OTP_NON_INTERACTIVE') return undefined
+  const urls: { authUrl?: string, doneUrl?: string } = {}
+  const authUrl = canonicalHttpUrl(error.authUrl)
+  if (authUrl != null) {
+    urls.authUrl = authUrl
+  }
+  const doneUrl = canonicalHttpUrl(error.doneUrl)
+  if (doneUrl != null) {
+    urls.doneUrl = doneUrl
+  }
+  return urls
+}
+
+function canonicalHttpUrl (value: unknown): string | undefined {
+  if (typeof value !== 'string') return undefined
+  try {
+    const url = new URL(value)
+    return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : undefined
+  } catch {
+    return undefined
+  }
Evidence
errorHandler now spreads getWebAuthUrls(error) into JSON output, and canonicalHttpUrl returns
url.href for http/https URLs without removing userinfo; the TS/Rust web-auth layers also preserve
URLs similarly. pnpm’s existing redactUrlCredentials helper documents that URL userinfo would
otherwise leak into error output, demonstrating this is a recognized sensitive pattern in this
codebase.

pnpm11/pnpm/src/errorHandler.ts[24-33]
pnpm11/pnpm/src/errorHandler.ts[84-106]
pnpm11/network/web-auth/src/withOtpHandling.ts[178-205]
pacquet/crates/network-web-auth/src/with_otp_handling.rs[124-147]
pnpm11/core/error/src/index.ts[65-76]

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

## Issue description
`authUrl`/`doneUrl` are emitted in `--json` error output and stored on OTP non-interactive errors after only scheme validation; URL serialization preserves any embedded userinfo (`user:pass@`). This can leak credentials into machine-readable output that is commonly logged.
### Issue Context
pnpm already has a dedicated helper to redact URL-embedded credentials when interpolating URLs in errors (`redactUrlCredentials`), implying userinfo is considered sensitive and should not be printed.
### Fix Focus Areas
- pnpm11/pnpm/src/errorHandler.ts[84-106]
- pnpm11/network/web-auth/src/withOtpHandling.ts[178-205]
- pacquet/crates/network-web-auth/src/with_otp_handling.rs[124-147]
### Suggested fix
1. Update the canonicalization helpers to either:
- **Strip userinfo** (preferred): if `username`/`password` is present, clear it before returning the canonical URL, or
- **Reject URLs with userinfo**: return `undefined`/`None` when userinfo is present.
TypeScript sketch:

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



Remediation recommended

2. Canonicalizer duplicated pacquet 🐞 Bug ⛨ Security
Description
pacquet now has two separate canonical_http_url implementations with different security behavior
(userinfo stripping in with_otp_handling.rs vs scheme-only in prompt_browser_open.rs), so
prompt_browser_open() can still open credential-bearing URLs if called directly and the two
sanitizers can drift. This inconsistency is introduced by adding the new canonicalizer rather than
reusing a single shared one.
Code

pacquet/crates/network-web-auth/src/with_otp_handling.rs[R144-161]

+/// Canonical serialization of an `http`/`https` URL with any userinfo
+/// (`user:pass@`) stripped; `None` for an unparsable URL or any other scheme.
+///
+/// These URLs come from the registry and get displayed, opened in a browser,
+/// and carried on errors for machine consumption: the scheme restriction
+/// keeps a malicious registry from injecting e.g. a `javascript:` URL into
+/// something that opens it, and stripping userinfo keeps credential-shaped
+/// data out of logs (the capability tokens automation needs live in the
+/// path/query, which are preserved).
+fn canonical_http_url(value: &str) -> Option<String> {
+    let mut parsed = url::Url::parse(value).ok()?;
+    if !matches!(parsed.scheme(), "http" | "https") {
+        return None;
+    }
+    parsed.set_username("").ok()?;
+    parsed.set_password(None).ok()?;
+    Some(parsed.to_string())
+}
Evidence
The PR adds a new userinfo-stripping canonicalizer in with_otp_handling.rs, while pacquet already
has a different canonical_http_url used by prompt_browser_open() that only checks scheme and
preserves userinfo. This creates inconsistent sanitation semantics across the crate.

pacquet/crates/network-web-auth/src/with_otp_handling.rs[124-161]
pacquet/crates/network-web-auth/src/prompt_browser_open.rs[28-44]
pacquet/crates/network-web-auth/src/prompt_browser_open.rs[79-85]

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

## Issue description
`pacquet/crates/network-web-auth` now defines `canonical_http_url()` twice with different behavior. The new implementation in `with_otp_handling.rs` strips userinfo and enforces `http/https`, but `prompt_browser_open.rs` still uses a scheme-only canonicalizer; because `prompt_browser_open()` is a public API intended for untrusted registry URLs, this leaves a weaker sanitation path and increases drift risk.
### Issue Context
The PR’s intent explicitly includes stripping userinfo to avoid credential-shaped data in logs/output. Having two implementations makes it easy to regress that guarantee in one call path.
### Fix Focus Areas
- pacquet/crates/network-web-auth/src/with_otp_handling.rs[144-161]
- pacquet/crates/network-web-auth/src/prompt_browser_open.rs[79-85]
### Suggested fix
1. Move a single `canonical_http_url` helper to a shared module (e.g. `src/url_sanitize.rs`) and re-use it from both files.
2. Ensure the shared helper:
- returns `None` for non-`http`/`https`
- strips userinfo (`user:pass@`) before serialization
3. Update `prompt_browser_open.rs` to call the shared helper (so direct callers also get userinfo stripping).

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


3. Timeout uncleared on error 🐞 Bug ☼ Reliability
Description
waitForPnpmExit() registers a process timeout but does not clear it on the child process error
event, so a spawn failure can leave the timer scheduled (keeping Jest alive until it fires) and
later execute timeout kill side-effects. This can cause test flakiness and unnecessary CI delays.
Code

pnpm11/pnpm/test/utils/execPnpm.ts[R86-115]

+export async function waitForPnpmExit (
+  proc: NodeChildProcess,
+  opts?: {
+    timeout?: number // timeout in ms
+  }
+): Promise<{ status: number | null, stdout: Buffer, stderr: Buffer }> {
+  return new Promise((resolve, reject) => {
+    const timeoutId = registerProcessTimeout(proc, opts?.timeout ?? DEFAULT_EXEC_PNPM_TIMEOUT, reject)
+
+    const stdout: Buffer[] = []
+    const stderr: Buffer[] = []
+    proc.stdout?.on('data', (chunk: Buffer) => {
+      stdout.push(chunk)
+    })
+    proc.stderr?.on('data', (chunk: Buffer) => {
+      stderr.push(chunk)
+    })
+
+    proc.on('error', reject)
+
+    proc.on('close', (code: number | null, signal: string | null) => {
+      clearTimeout(timeoutId)
+
+      if (signal) {
+        reject(new Error(`Killed by signal ${signal}\n\n${Buffer.concat([...stdout, ...stderr]).toString()}`))
+      } else {
+        resolve({ status: code, stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr) })
+      }
+    })
+  })
Evidence
waitForPnpmExit() attaches proc.on('error', reject) without clearing the timeout, while the
timeout registered by registerProcessTimeout() is a normal setTimeout that will remain pending
and later perform kill logic unless cleared.

pnpm11/pnpm/test/utils/execPnpm.ts[86-115]
pnpm11/pnpm/test/utils/execPnpm.ts[271-285]

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

## Issue description
In `waitForPnpmExit()`, the `registerProcessTimeout()` timer is only cleared in the `close` handler. If the child emits an `error` event (e.g. spawn failure) and `close` does not run, the timeout remains scheduled and may keep the test runner alive until it fires.
### Issue Context
`registerProcessTimeout()` uses `setTimeout()` (not `unref()`), so it will keep the event loop alive unless cleared.
### Fix Focus Areas
- pnpm11/pnpm/test/utils/execPnpm.ts[86-115]
- pnpm11/pnpm/test/utils/execPnpm.ts[271-285]
### Suggested fix
- In `waitForPnpmExit()`, wrap cleanup into a single `finalize()` that:
- `clearTimeout(timeoutId)`
- removes listeners (or use `once()` handlers)
- Call `finalize()` from both the `error` and `close` handlers before rejecting/resolving.
- Consider using `proc.once('error', ...)` / `proc.once('close', ...)` to avoid duplicate cleanup paths.

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


4. Unnecessary web-auth import 🐞 Bug ➹ Performance
Description
pnpm/src/errorHandler.ts imports canonicalHttpUrl from @pnpm/network.web-auth just to sanitize
JSON error fields, which forces pnpm’s core error handler to depend on (and load) the full web-auth
module graph. This adds avoidable module-load overhead/coupling for a hot startup/error-path file,
even when web-auth functionality is not needed.
Code

pnpm11/pnpm/src/errorHandler.ts[4]

+import { canonicalHttpUrl } from '@pnpm/network.web-auth'
Evidence
The new import in pnpm’s error handler pulls canonicalHttpUrl from the web-auth package
entrypoint, whose re-exports require loading modules like withOtpHandling and promptBrowserOpen;
those modules import other web-auth machinery and even the open dependency at module top-level.
This shows the helper is not isolated and expands the module graph loaded by pnpm’s core error path.

pnpm11/pnpm/src/errorHandler.ts[1-6]
pnpm11/pnpm/src/errorHandler.ts[85-97]
pnpm11/network/web-auth/src/index.ts[1-28]
pnpm11/network/web-auth/src/withOtpHandling.ts[1-8]
pnpm11/network/web-auth/src/promptBrowserOpen.ts[1-6]

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

## Issue description
`pnpm11/pnpm/src/errorHandler.ts` imports `canonicalHttpUrl` from `@pnpm/network.web-auth` for simple scheme validation/canonicalization. Because `@pnpm/network.web-auth`’s entrypoint re-exports many modules, importing this helper can load unrelated web-auth code (QR generation, polling, browser-open).
### Issue Context
This import sits in pnpm’s core error-handling module, which is loaded on every CLI invocation. The helper itself is tiny; the import graph expansion is the main concern.
### How to fix
Choose one of these approaches:
1. **Inline a local helper in `errorHandler.ts`** (smallest change): copy the `canonicalHttpUrl` implementation into `pnpm11/pnpm/src/errorHandler.ts` and remove the dependency/import on `@pnpm/network.web-auth` from pnpm.
2. **Create a lightweight shared utility module** (better long-term):
- Move `canonicalHttpUrl` into a small file that has **no imports** from web-auth flow code (e.g. `pnpm11/network/web-auth/src/urlUtils.ts`).
- Update `promptBrowserOpen.ts` and `withOtpHandling.ts` to reuse it.
- Export it via a **subpath export** (e.g. `@pnpm/network.web-auth/urlUtils`) so consumers like pnpm can import the helper without pulling in the full index.
### Fix Focus Areas
- pnpm11/pnpm/src/errorHandler.ts[1-6]
- pnpm11/pnpm/src/errorHandler.ts[85-97]
- pnpm11/network/web-auth/src/index.ts[1-28]
- pnpm11/network/web-auth/src/withOtpHandling.ts[1-8]
- pnpm11/network/web-auth/src/withOtpHandling.ts[197-211]
- pnpm11/network/web-auth/src/promptBrowserOpen.ts[1-6]

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


View more (3)
5. Timeout force-kill condition inverted 🐞 Bug ☼ Reliability
Description
waitForPnpmExit() uses registerProcessTimeout() for cleanup, but the grace-period branch only
calls proc.kill() when proc.exitCode != null (already exited), so timed-out child processes may
remain running and keep Jest/CI stuck. This undermines the new helper’s primary purpose of safely
asserting on failing invocations.
Code

pnpm11/pnpm/test/utils/execPnpm.ts[R86-115]

+export async function waitForPnpmExit (
+  proc: NodeChildProcess,
+  opts?: {
+    timeout?: number // timeout in ms
+  }
+): Promise<{ status: number | null, stdout: Buffer, stderr: Buffer }> {
+  return new Promise((resolve, reject) => {
+    const timeoutId = registerProcessTimeout(proc, opts?.timeout ?? DEFAULT_EXEC_PNPM_TIMEOUT, reject)
+
+    const stdout: Buffer[] = []
+    const stderr: Buffer[] = []
+    proc.stdout?.on('data', (chunk: Buffer) => {
+      stdout.push(chunk)
+    })
+    proc.stderr?.on('data', (chunk: Buffer) => {
+      stderr.push(chunk)
+    })
+
+    proc.on('error', reject)
+
+    proc.on('close', (code: number | null, signal: string | null) => {
+      clearTimeout(timeoutId)
+
+      if (signal) {
+        reject(new Error(`Killed by signal ${signal}\n\n${Buffer.concat([...stdout, ...stderr]).toString()}`))
+      } else {
+        resolve({ status: code, stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr) })
+      }
+    })
+  })
Evidence
The new helper calls registerProcessTimeout(), and the timeout implementation’s grace-period kill
path is guarded by proc.exitCode != null, meaning it skips killing processes that have not exited
(where exitCode remains null).

pnpm11/pnpm/test/utils/execPnpm.ts[86-115]
pnpm11/pnpm/test/utils/execPnpm.ts[271-285]

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 newly-added `waitForPnpmExit()` depends on `registerProcessTimeout()` to kill a stuck pnpm process. However, `registerProcessTimeout()` currently attempts the post-grace kill only when `proc.exitCode != null`, which is the opposite of the intended condition (still running), so stuck processes may not be terminated.
### Issue Context
This can leave open handles/child processes during tests, causing CI flakiness or hangs.
### Fix Focus Areas
- Flip the exit-code check to kill only when the process is still running (`exitCode == null`).
- Consider wrapping `proc.kill(...)` calls in try/catch and unref-ing the grace timer to reduce open-handle risk.
- pnpm11/pnpm/test/utils/execPnpm.ts[86-115]
- pnpm11/pnpm/test/utils/execPnpm.ts[271-285]

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


6. Test lacks timeout guard 🐞 Bug ☼ Reliability
Description
The new JSON error output test waits for server.listen() and for the spawned pnpm process to exit
without any timeout safeguard, so a bind failure or stuck child process can leave the test pending
until Jest’s global timeout (wasting CI time and obscuring failure causes). This is introduced in
the new test via Promises that never reject on server errors and don’t enforce an upper bound on
proc lifetime.
Code

pnpm11/pnpm/test/errorHandler.test.ts[R52-77]

+    await new Promise<void>((resolve) => {
+      server.listen(0, '127.0.0.1', resolve)
+    })
+    const { port } = server.address() as AddressInfo
+    const proc = spawnPnpm([
+      'dist-tag',
+      'add',
+      '[email protected]',
+      'beta',
+      '--json',
+      `--registry=http://127.0.0.1:${port}/`,
+    ])
+    const stdout: Buffer[] = []
+    const stderr: Buffer[] = []
+    proc.stdout!.on('data', (chunk: Buffer) => stdout.push(chunk))
+    proc.stderr!.on('data', (chunk: Buffer) => stderr.push(chunk))
+    const status = await new Promise<number | null>((resolve, reject) => {
+      proc.on('error', reject)
+      proc.on('close', (code: number | null, signal: string | null) => {
+        if (signal) {
+          reject(new Error(`Killed by signal ${signal}\n\n${Buffer.concat([...stdout, ...stderr]).toString()}`))
+        } else {
+          resolve(code)
+        }
+      })
+    })
Evidence
The test awaits server.listen() with a Promise that never rejects on error, and awaits
proc.close without any timeout; meanwhile the test utilities show a pattern
(registerProcessTimeout) used elsewhere specifically to avoid hung child processes.

pnpm11/pnpm/test/errorHandler.test.ts[32-77]
pnpm11/pnpm/test/utils/execPnpm.ts[14-61]
pnpm11/pnpm/test/utils/execPnpm.ts[233-248]

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 test spawns a child process and starts an HTTP server, then awaits events with Promises that can remain pending forever (no timeout, and `server.listen()` Promise doesn’t reject on listen errors).
### Issue Context
This only affects test/CI reliability, but if pnpm hangs or the server fails to bind, the suite can stall until Jest’s global timeout.
### Fix Focus Areas
- pnpm11/pnpm/test/errorHandler.test.ts[52-77]
- pnpm11/pnpm/test/utils/execPnpm.ts[14-61]
- pnpm11/pnpm/test/utils/execPnpm.ts[233-248]
### What to change
1) Wrap `server.listen(...)` in a Promise that also rejects on `server.once('error', reject)`.
2) Add an explicit timeout around waiting for `proc` to close (e.g., `Promise.race([closePromise, timeoutPromise])` that kills the process and rejects), similar to how `registerProcessTimeout()` bounds `execPnpm` in `execPnpm.ts`.
3) Ensure cleanup occurs on timeout/error (kill proc, close server).

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


7. Unvalidated URLs in JSON ✓ Resolved 🐞 Bug ⛨ Security
Description
errorHandler now copies error.authUrl/error.doneUrl into machine-readable JSON output using
only a string type check, so untrusted registry-provided values (or any thrown error’s properties)
can be emitted unchanged. This doesn’t directly open/fetch the URL in pnpm, but it increases
downstream risk for wrapper tools that may automatically open/poll these fields unless pnpm scopes
and validates them (e.g., restrict to ERR_PNPM_OTP_NON_INTERACTIVE and http/https only).
Code

pnpm11/pnpm/src/errorHandler.ts[R84-93]

+function getWebAuthUrls (error: Error & { authUrl?: unknown, doneUrl?: unknown }): { authUrl?: string, doneUrl?: string } {
+  const urls: { authUrl?: string, doneUrl?: string } = {}
+  if (typeof error.authUrl === 'string') {
+    urls.authUrl = error.authUrl
+  }
+  if (typeof error.doneUrl === 'string') {
+    urls.doneUrl = error.doneUrl
+  }
+  return urls
+}
Evidence
The new getWebAuthUrls helper forwards any string-valued authUrl/doneUrl from an error into
JSON output without scheme validation or scoping, while the existing interactive browser-open path
explicitly restricts untrusted authUrl to http(s). This demonstrates that the JSON output path is
missing the same safety gate used elsewhere for the same untrusted input.

pnpm11/pnpm/src/errorHandler.ts[24-33]
pnpm11/pnpm/src/errorHandler.ts[84-93]
pnpm11/network/web-auth/src/promptBrowserOpen.ts[44-55]
pnpm11/network/web-auth/src/withOtpHandling.ts[178-192]

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

## Issue description
pnpm’s JSON error output now includes `authUrl`/`doneUrl` whenever the thrown error object has string-valued properties with those names. These values originate from attacker-controlled registry responses in the OTP flow, and unlike the interactive browser-open path, they are not validated/canonicalized to http(s), nor scoped to the OTP non-interactive error type.
## Issue Context
- `promptBrowserOpen` treats `authUrl` as untrusted and explicitly allows only `http:`/`https:` before passing it to `open()`.
- The new JSON output path will emit any string `authUrl`/`doneUrl` on any error, which can be consumed by wrapper tooling.
## Fix Focus Areas
- pnpm11/pnpm/src/errorHandler.ts[24-33]
- pnpm11/pnpm/src/errorHandler.ts[84-93]
- pnpm11/network/web-auth/src/promptBrowserOpen.ts[44-55]
- pnpm11/network/web-auth/src/withOtpHandling.ts[178-192]
- pacquet/crates/network-web-auth/src/with_otp_handling.rs[124-141]
## What to change
1. Scope emission in `getWebAuthUrls()` to the intended error:
- e.g. only include URLs when `error.code === 'ERR_PNPM_OTP_NON_INTERACTIVE'` (or when `error` is an `OtpNonInteractiveError`-like shape).
2. Validate/canonicalize URLs before emitting:
- Parse with `new URL(...)` and only allow `http:`/`https:`.
- If parsing fails or protocol is not allowed, omit the field.
- Consider applying the same check to both `authUrl` and `doneUrl`.
3. (Parity) Consider applying the same canonicalization at the source error types (`OtpNonInteractiveError` in TS and Rust) so all downstream surfaces get the same safety properties.

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


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 3, 2026
@codecov-commenter

codecov-commenter commented Jul 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.59%. Comparing base (a6c4d5f) to head (f6b4d39).

Files with missing lines Patch % Lines
...t/crates/network-web-auth/src/with_otp_handling.rs 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12786      +/-   ##
==========================================
- Coverage   85.59%   85.59%   -0.01%     
==========================================
  Files         413      413              
  Lines       64137    64158      +21     
==========================================
+ Hits        54901    54917      +16     
- Misses       9236     9241       +5     

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: f6b4d39be87f

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 4.019 ± 0.158 3.869 4.389 1.92 ± 0.12
pacquet@main 4.020 ± 0.152 3.825 4.209 1.92 ± 0.12
pnpr@HEAD 2.097 ± 0.104 1.963 2.288 1.00
pnpr@main 2.145 ± 0.131 1.973 2.339 1.02 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.019074860999999,
      "stddev": 0.1581821854176039,
      "median": 3.9798675904000005,
      "user": 3.81108476,
      "system": 3.5061020399999996,
      "min": 3.8693840654000002,
      "max": 4.3888700094,
      "times": [
        3.9962603194,
        3.9071464324000003,
        3.9946786264000003,
        3.9957279154000003,
        4.3888700094,
        3.9650565544000003,
        3.8693840654000002,
        3.9168798754000003,
        4.2037831813999995,
        3.9529616304000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.019800314700001,
      "stddev": 0.15190023024107788,
      "median": 3.9793220009,
      "user": 3.8033561600000008,
      "system": 3.5117419400000003,
      "min": 3.8252580934,
      "max": 4.209274038399999,
      "times": [
        4.202786952399999,
        3.9025076864000003,
        4.1691003484,
        3.9035454794000004,
        3.9466498584000003,
        3.8628178354,
        4.209274038399999,
        4.1640687114,
        4.0119941434,
        3.8252580934
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.0971699480000003,
      "stddev": 0.10368422241489311,
      "median": 2.0944614344000003,
      "user": 2.63137646,
      "system": 3.0297172400000005,
      "min": 1.9633663564000001,
      "max": 2.2879797384000002,
      "times": [
        1.9633663564000001,
        2.0305408764000004,
        2.0951558704,
        2.1336841024,
        1.9658886173999999,
        2.0324567584000004,
        2.2879797384000002,
        2.1855221144000003,
        2.1833380474000004,
        2.0937669984
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.1451977751,
      "stddev": 0.13103598940327188,
      "median": 2.1248259489,
      "user": 2.61903346,
      "system": 3.0321310400000003,
      "min": 1.9732458914000002,
      "max": 2.3390471164,
      "times": [
        2.1691440584,
        2.2755055694000004,
        2.0947679144,
        2.1548839834,
        1.9732458914000002,
        2.0778479754,
        2.0750894194000002,
        2.3390471164,
        1.9763037554,
        2.3161420674000004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 657.5 ± 8.6 642.2 667.5 1.02 ± 0.03
pacquet@main 645.2 ± 17.6 626.5 677.7 1.00
pnpr@HEAD 719.1 ± 47.1 678.5 836.9 1.11 ± 0.08
pnpr@main 719.7 ± 89.3 676.6 971.3 1.12 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6574853117600001,
      "stddev": 0.008583829085382695,
      "median": 0.6601232296600001,
      "user": 0.38281796,
      "system": 1.3343146799999999,
      "min": 0.6422196571600001,
      "max": 0.6675224191600001,
      "times": [
        0.6422196571600001,
        0.6546458331600001,
        0.6658617021600001,
        0.6650388601600001,
        0.6482563611600001,
        0.6489261961600001,
        0.6675224191600001,
        0.6603446451600001,
        0.6621356291600001,
        0.65990181416
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6451633571600001,
      "stddev": 0.017565237427135425,
      "median": 0.6421018036600001,
      "user": 0.37197576000000004,
      "system": 1.33446838,
      "min": 0.62646944816,
      "max": 0.6777174911600001,
      "times": [
        0.6777174911600001,
        0.62646944816,
        0.6270798001600001,
        0.63884203916,
        0.6723005391600001,
        0.6318823691600001,
        0.6453615681600001,
        0.64953889216,
        0.63688796816,
        0.6455534561600001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.71914814266,
      "stddev": 0.04709039614737208,
      "median": 0.7039196416600001,
      "user": 0.38738006,
      "system": 1.3793637799999998,
      "min": 0.6784858171600001,
      "max": 0.8369498941600001,
      "times": [
        0.6830008881600002,
        0.7391501421600001,
        0.7027139951600001,
        0.7472513281600001,
        0.6784858171600001,
        0.7051252881600001,
        0.7120609721600001,
        0.6868691181600001,
        0.69987398316,
        0.8369498941600001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7197198823600001,
      "stddev": 0.08925990891430102,
      "median": 0.6905250566600001,
      "user": 0.39139826000000005,
      "system": 1.3558735799999997,
      "min": 0.6766005211600001,
      "max": 0.9713269261600002,
      "times": [
        0.9713269261600002,
        0.6766005211600001,
        0.7073329011600001,
        0.70210999916,
        0.68952540116,
        0.7132230771600001,
        0.6857657131600001,
        0.6786282971600001,
        0.6811612751600001,
        0.6915247121600001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.247 ± 0.037 4.160 4.293 1.91 ± 0.09
pacquet@main 4.242 ± 0.027 4.171 4.271 1.91 ± 0.09
pnpr@HEAD 2.219 ± 0.105 2.074 2.379 1.00
pnpr@main 2.264 ± 0.140 1.989 2.441 1.02 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.246751580520001,
      "stddev": 0.03654914606318729,
      "median": 4.25657431422,
      "user": 3.76116194,
      "system": 3.3917388600000002,
      "min": 4.15957548322,
      "max": 4.29280693822,
      "times": [
        4.25670866322,
        4.2704883352200005,
        4.26292132222,
        4.2139306562200005,
        4.242155690220001,
        4.25643996522,
        4.29280693822,
        4.257876678220001,
        4.15957548322,
        4.254612073220001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.2418060434200004,
      "stddev": 0.02711358145667529,
      "median": 4.24644774522,
      "user": 3.7546459399999996,
      "system": 3.39418936,
      "min": 4.171262239220001,
      "max": 4.271140514220001,
      "times": [
        4.232965618220001,
        4.271140514220001,
        4.252700213220001,
        4.24859385522,
        4.24419677822,
        4.26383552522,
        4.240470200220001,
        4.24591024422,
        4.171262239220001,
        4.24698524622
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.2190656798199995,
      "stddev": 0.1046919684058826,
      "median": 2.20501100372,
      "user": 2.50354154,
      "system": 2.91296236,
      "min": 2.07366605422,
      "max": 2.37914817822,
      "times": [
        2.17963045522,
        2.37914817822,
        2.07366605422,
        2.15314529622,
        2.30761600722,
        2.28066970722,
        2.33045840222,
        2.22903305122,
        2.1809889562199998,
        2.07630069022
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.2640324256199995,
      "stddev": 0.14033727671943685,
      "median": 2.28407894522,
      "user": 2.4545987400000002,
      "system": 2.93001676,
      "min": 1.9893653092200003,
      "max": 2.44076589022,
      "times": [
        2.44076589022,
        2.16417517822,
        1.9893653092200003,
        2.27992218522,
        2.21444070922,
        2.28823570522,
        2.37066890522,
        2.38947945222,
        2.1293868152199997,
        2.37388410622
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.345 ± 0.006 1.336 1.350 2.05 ± 0.02
pacquet@main 1.355 ± 0.036 1.325 1.453 2.06 ± 0.06
pnpr@HEAD 0.674 ± 0.057 0.643 0.835 1.03 ± 0.09
pnpr@main 0.656 ± 0.007 0.645 0.667 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.34502388262,
      "stddev": 0.005574121467750468,
      "median": 1.3473480260200001,
      "user": 1.3168792799999998,
      "system": 1.6899763399999999,
      "min": 1.33627891252,
      "max": 1.35035850852,
      "times": [
        1.33897661852,
        1.34655547552,
        1.33679733752,
        1.33627891252,
        1.34852972052,
        1.34814057652,
        1.35035850852,
        1.34934404852,
        1.34499502752,
        1.35026260052
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.3547408907200003,
      "stddev": 0.03626766243466942,
      "median": 1.34498147652,
      "user": 1.31493318,
      "system": 1.70078444,
      "min": 1.32522823552,
      "max": 1.45251438352,
      "times": [
        1.32522823552,
        1.34641610252,
        1.45251438352,
        1.34080633252,
        1.35294952352,
        1.3630524345200001,
        1.33312716652,
        1.33294882352,
        1.3435468505200001,
        1.35681905452
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6741575409200001,
      "stddev": 0.05686624821191555,
      "median": 0.65664731952,
      "user": 0.33880718,
      "system": 1.29005184,
      "min": 0.64255239152,
      "max": 0.83459030852,
      "times": [
        0.65188603852,
        0.66815607652,
        0.64255239152,
        0.65693743852,
        0.65204190852,
        0.83459030852,
        0.66775351052,
        0.65394722052,
        0.65635720052,
        0.65735331552
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.65640535292,
      "stddev": 0.007317361641002803,
      "median": 0.65697024152,
      "user": 0.33181057999999997,
      "system": 1.2886915399999999,
      "min": 0.64543275052,
      "max": 0.66724086252,
      "times": [
        0.65142267552,
        0.65775010052,
        0.66043332452,
        0.65959243452,
        0.66724086252,
        0.64543275052,
        0.64551752852,
        0.66488003052,
        0.6561903825200001,
        0.65559343952
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.012 ± 0.047 2.967 3.134 4.47 ± 0.14
pacquet@main 3.036 ± 0.032 3.000 3.100 4.51 ± 0.13
pnpr@HEAD 0.679 ± 0.010 0.667 0.696 1.01 ± 0.03
pnpr@main 0.674 ± 0.018 0.647 0.709 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.0120271467400004,
      "stddev": 0.04744828135115549,
      "median": 3.0022271394399995,
      "user": 1.7740831000000004,
      "system": 1.9926120399999996,
      "min": 2.96707225194,
      "max": 3.13394837894,
      "times": [
        2.98295326594,
        3.02138372194,
        3.02587926494,
        3.02238179994,
        3.00004567294,
        3.0044086059399997,
        2.9849542469399997,
        2.96707225194,
        3.13394837894,
        2.97724425794
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.0357596789400003,
      "stddev": 0.03202606849862977,
      "median": 3.0300392444399997,
      "user": 1.7780828,
      "system": 1.99969264,
      "min": 3.0000375449399996,
      "max": 3.10047515494,
      "times": [
        3.0469705599399997,
        3.02184411394,
        3.0016769859399997,
        3.0000375449399996,
        3.07379698794,
        3.0166872679399996,
        3.0382343749399996,
        3.0152240839399997,
        3.10047515494,
        3.04264971494
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6786088022400001,
      "stddev": 0.009620921560667238,
      "median": 0.6756635174400001,
      "user": 0.32985669999999995,
      "system": 1.33691574,
      "min": 0.6673782679400001,
      "max": 0.6960274379400001,
      "times": [
        0.6673782679400001,
        0.6855205929400001,
        0.69019395894,
        0.67073423994,
        0.6831896609400001,
        0.6713200729400001,
        0.6751018119400001,
        0.67039675594,
        0.6960274379400001,
        0.6762252229400001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.67362703764,
      "stddev": 0.01831952590119144,
      "median": 0.6705067864400001,
      "user": 0.33125629999999995,
      "system": 1.2946798400000001,
      "min": 0.6465943389400001,
      "max": 0.70902434394,
      "times": [
        0.6754600759400001,
        0.6705225289400001,
        0.6971158149400001,
        0.66189747194,
        0.67049104394,
        0.68002463694,
        0.6669932139400001,
        0.6465943389400001,
        0.70902434394,
        0.6581469069400001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.913 ± 0.212 6.641 7.342 1.40 ± 0.05
pacquet@main 6.813 ± 0.162 6.660 7.190 1.38 ± 0.04
pnpr@HEAD 4.933 ± 0.099 4.817 5.142 1.00
pnpr@main 4.990 ± 0.097 4.807 5.136 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.91289481992,
      "stddev": 0.21204675401704834,
      "median": 6.85294487102,
      "user": 4.0132145999999995,
      "system": 3.7703921199999995,
      "min": 6.64114346852,
      "max": 7.34188706452,
      "times": [
        6.9935011955199995,
        7.1366235715199995,
        7.00127974352,
        6.83103741452,
        6.87485232752,
        6.80169531652,
        6.64114346852,
        6.67903987252,
        7.34188706452,
        6.82788822452
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.813121745719999,
      "stddev": 0.1620843091361096,
      "median": 6.78410327002,
      "user": 3.9860967999999994,
      "system": 3.8349344199999997,
      "min": 6.659840336519999,
      "max": 7.18994971352,
      "times": [
        6.81575231452,
        6.98104358252,
        6.82657788452,
        7.18994971352,
        6.70195152652,
        6.70148264052,
        6.78448579552,
        6.659840336519999,
        6.686412918519999,
        6.78372074452
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 4.933400047419999,
      "stddev": 0.09897510871052934,
      "median": 4.913537896519999,
      "user": 2.7818237,
      "system": 3.23970512,
      "min": 4.81669123052,
      "max": 5.14175156952,
      "times": [
        4.90313505152,
        4.81669123052,
        5.04460658352,
        4.92394074152,
        4.89615752052,
        4.95074145252,
        4.96260652652,
        5.14175156952,
        4.86049185752,
        4.83387794052
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.989766767019999,
      "stddev": 0.09708630321750931,
      "median": 5.00272359502,
      "user": 2.7357039999999992,
      "system": 3.2732509199999997,
      "min": 4.80706189852,
      "max": 5.13558879452,
      "times": [
        4.91311699252,
        4.99991073452,
        5.13558879452,
        4.80706189852,
        5.00553645552,
        5.07090071052,
        5.05026062752,
        4.91246830052,
        5.06253182252,
        4.94029133352
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12786
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
4,246.75 ms
(-5.11%)Baseline: 4,475.62 ms
5,370.74 ms
(79.07%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,012.03 ms
(-1.53%)Baseline: 3,058.75 ms
3,670.50 ms
(82.06%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,345.02 ms
(-1.39%)Baseline: 1,363.99 ms
1,636.79 ms
(82.17%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,019.07 ms
(-7.98%)Baseline: 4,367.73 ms
5,241.28 ms
(76.68%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,912.89 ms
(-1.98%)Baseline: 7,052.43 ms
8,462.92 ms
(81.68%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
657.49 ms
(+4.46%)Baseline: 629.39 ms
755.27 ms
(87.05%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12786
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
2,219.07 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
678.61 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
674.16 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,097.17 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
4,933.40 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
719.15 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan force-pushed the expose-non-tty-web-auth-urls branch from a068d70 to ad434fc Compare July 3, 2026 14:17
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

zkochan added 2 commits July 3, 2026 16:53
…upe URL validation

The e2e test drove the OTP flow through `pnpm dist-tag add --json`, but
dist-tag does not accept --json, so the spawned pnpm exited on an
unknown-option error before ever reaching the mock registry. Drive the
flow through `pnpm publish --json` instead — the use case reported in
pnpm#12724 — against a mock registry that answers 401 with a
www-authenticate OTP challenge, which exercises the full path end to end.

Also address review feedback and conventions:

- add a waitForPnpmExit() test util that guards the spawned process with
  the shared timeout instead of hand-rolled exit waiting, and make the
  test's server.listen() reject on bind errors
- export canonicalHttpUrl from `@pnpm/network.web-auth` and reuse it in
  the pnpm error handler instead of keeping a copy
- bump the changeset to minor: the new JSON error output fields are a
  user-facing feature
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@Andarist

Andarist commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

@zkochan this was supposed to be opened as a draft - I had a bunch of issues running things locally (now resolved) so I wanted to leverage CI to do some testing for me. I was iterating on this in the background but I see you are pushing here now so I guess it's best for me to wait till you pause/finish this. Happy to refine this further into whatever direction you'd like

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

Strip userinfo (user:pass@) from authUrl/doneUrl before they are carried
on OtpNonInteractiveError and emitted in --json error output. The URLs
are registry-supplied and commonly end up in CI logs; the capability
tokens automation needs live in the path/query, which are preserved, so
consumers are unaffected while credential-shaped data stays out of logs.

Validate the same URLs on the interactive path too: the web-auth flow
previously printed, QR-encoded, and auto-opened the challenge authUrl
verbatim, so a malicious registry could get a file: or custom-protocol
URL launched through the OS handler. Non-http(s) URLs now fall back to
the classic OTP prompt.

Applied to both the TypeScript CLI and pacquet, with matching tests.

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

🧹 Nitpick comments (1)
pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs (1)

336-343: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: add debug output for the multi-line URL assertion.

Per pacquet's style guide, complex/multi-line assertion values benefit from eprintln!/dbg! before the assert to aid failure diagnosis (e.g., the done_url with query string).

As per path instructions, "use logging (eprintln!/dbg!) when assertions involve complex or multi-line values".

🤖 Prompt for 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.

In `@pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs` around lines
336 - 343, The assertions in the WithOtpError::NonInteractive test compare
complex URL values across multiple lines, so add temporary debug output before
the assertions to aid failure diagnosis. Update the test around the match on
WithOtpError::NonInteractive in with_otp_handling/tests.rs to print the relevant
fields (especially auth_url and done_url) using eprintln! or dbg! before the
assert_eq! calls, keeping the existing assertions unchanged.

Source: Path instructions

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

Nitpick comments:
In `@pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs`:
- Around line 336-343: The assertions in the WithOtpError::NonInteractive test
compare complex URL values across multiple lines, so add temporary debug output
before the assertions to aid failure diagnosis. Update the test around the match
on WithOtpError::NonInteractive in with_otp_handling/tests.rs to print the
relevant fields (especially auth_url and done_url) using eprintln! or dbg!
before the assert_eq! calls, keeping the existing assertions unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 381d2608-2b26-4a62-88bf-f6a14aff8ec5

📥 Commits

Reviewing files that changed from the base of the PR and between 1645864 and f6b4d39.

📒 Files selected for processing (4)
  • pacquet/crates/network-web-auth/src/with_otp_handling.rs
  • pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs
  • pnpm11/network/web-auth/src/withOtpHandling.ts
  • pnpm11/network/web-auth/test/withOtpHandling.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • pacquet/crates/network-web-auth/src/with_otp_handling.rs
  • pnpm11/network/web-auth/src/withOtpHandling.ts

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@zkochan
zkochan merged commit 1e81761 into pnpm:main Jul 3, 2026
44 of 46 checks passed
@welcome

welcome Bot commented Jul 3, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

return 2fa auth information in ERR_PNPM_OTP_NON_INTERACTIVE

3 participants