fix(agents): classify auth HTML provider responses#79900
Conversation
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. from source inspection. Current main accepts 401 HTML as an HTML error response but only status 403 maps to auth copy, so 401 falls through to PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the focused classifier, formatter, raw-console suppression, and regression-test update after required CI completes successfully on the latest head. Do we have a high-confidence way to reproduce the issue? Yes, from source inspection. Current main accepts 401 HTML as an HTML error response but only status 403 maps to auth copy, so 401 falls through to Is this the best way to solve the issue? Yes. Extending the existing HTML auth branch to include 401 and centralizing auth HTML console-suffix suppression is narrower than changing provider routing, and the PR preserves Label changes:
Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 016c34ff1d2a. |
74d2189 to
128c615
Compare
|
Friendly ping — anything blocking a review here? |
128c615 to
62be466
Compare
62be466 to
898dcc2
Compare
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Cosmic Review Wisp Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
898dcc2 to
8badd65
Compare
8badd65 to
4f9fa7d
Compare
4f9fa7d to
3e0f59e
Compare
d50980e to
1c5edaf
Compare
1c5edaf to
c63cf7e
Compare
fe31636 to
69e47c8
Compare
…am_html A provider returning an HTML 401 body (Cloudflare Access login page, nginx basic-auth challenge, gateway login wall) was previously classified as `upstream_html` and shown the CDN-blocked retry copy to the end user. Add `auth_html_401` kind; update classifier to branch on status === 401 before the fallback `upstream_html` arm; add matching formatter copy and two regression tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
69e47c8 to
b005134
Compare
|
Merged via squash.
Thanks @martingarramon! |
Summary
classifyProviderRuntimeFailureKindreturnsupstream_html("CDN or gateway blocked the request — retry") for providers that return an HTML body with HTTP 401. 401 HTML auth/login responses land here; users get retry copy when the actual remediation is re-authentication.auth_html_403kind was added previously with the correct re-auth copy for 403s. The 401 arm was simply not branched —errors.ts:939-940readsreturn status === 403 ? "auth_html_403" : "upstream_html", so any 401 + HTML body falls through.auth_html_401toProviderRuntimeFailureKind, updated the classifier branch, added formatter copy, and two regression tests.auth_html_403formatter,upstream_htmlpath for non-401/403 HTML bodies,isHtmlErrorResponsedetection logic.Change Type: Bug fix
Scope: Auth / tokens
Linked: Related #77394 (same
classifyProviderRuntimeFailureKindfunction, HTML auth classification)Classifier proof
Source trace:
errors.ts:939-940— the 401 arm was absent from the ternary; a 401 with HTML body entersupstream_htmland returns "CDN or gateway blocked the request."Regression tests assert (1)
401 <!DOCTYPE html>…→ re-auth copy, (2) that input does NOT produce "CDN" or "blocked the request."Structural proof: fix mirrors the existing
auth_html_403pattern exactly.Real behavior proof
Behavior or issue addressed: HTTP 401 + HTML body (Cloudflare Access login page, nginx basic-auth challenge, gateway login wall) was classified as
upstream_html, showing users "CDN or gateway blocked the request — retry." The actual remediation is re-authentication, not retry. This fix adds the missing 401 arm so those responses reach the correct copy.Real environment tested: Node.js v24.14.0, Ubuntu 24.04 on WSL2. Logic exercised using the real
HTML_BODY_RE/HTML_CLOSE_REconstants and the exact classifier branch from commit 128c615.Exact steps or command run after this patch:
Script calls
classifyProviderRuntimeFailureKindandformatAssistantErrorTextwith a 401 HTML body, using the real constants fromsrc/agents/pi-embedded-helpers/errors.ts.Evidence after fix:
Observed result after fix:
classifyProviderRuntimeFailureKindreturnsauth_html_401for a 401 + HTML body (previouslyupstream_html).formatAssistantErrorTextreturns re-authentication copy, not CDN retry copy.What was not tested: End-to-end through a live provider network call. The classifier receives an already-fetched response body and HTTP status code — the path from those two inputs to the returned kind is deterministic and was exercised by the above trace.