Repository navigation
Expose web authentication authUrl and doneUrl in JSON error output when OTP is required in a non-interactive terminal - #12786
Conversation
PR Summary by QodoExpose web-auth authUrl/doneUrl in JSON OTP non-interactive errors
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe PR propagates OTP ChangesOTP Non-Interactive Error URL Propagation
Estimated code review effort: 3 (Moderate) | ~25 minutes Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
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
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. Comment |
Code Review by Qodo
1. Userinfo not redacted
|
|
Code review by qodo was updated up to the latest commit 9431717 |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
Code review by qodo was updated up to the latest commit a068d70 |
1 similar comment
|
Code review by qodo was updated up to the latest commit a068d70 |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
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
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
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
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
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
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
]
}
]
} |
|
| Branch | pr/12786 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,219.07 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 678.61 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 674.16 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,097.17 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,933.40 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 719.15 ms |
…t when OTP is required in a non-interactive terminal
a068d70 to
ad434fc
Compare
|
Code review by qodo was updated up to the latest commit ad434fc |
1 similar comment
|
Code review by qodo was updated up to the latest commit ad434fc |
…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
|
Code review by qodo was updated up to the latest commit 1645864 |
|
@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 |
|
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.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pacquet/crates/network-web-auth/src/with_otp_handling/tests.rs (1)
336-343: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: 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., thedone_urlwith 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
📒 Files selected for processing (4)
pacquet/crates/network-web-auth/src/with_otp_handling.rspacquet/crates/network-web-auth/src/with_otp_handling/tests.rspnpm11/network/web-auth/src/withOtpHandling.tspnpm11/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
|
Code review by qodo was updated up to the latest commit f6b4d39 |
1 similar comment
|
Code review by qodo was updated up to the latest commit f6b4d39 |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
Summary
Expose web-auth OTP challenge URLs in
--jsonerror output when pnpm is running non-interactively.When the registry returns
authUrlanddoneUrl, pnpm now preserves them on the non-interactive OTP error and includes them aserror.authUrlanderror.doneUrlin 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
Checklist
pacquet/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Summary by CodeRabbit
Summary by CodeRabbit
authUrlanddoneUrl(as validhttp/httpsURLs).http/httpsvalues are omitted.http/https.