Repository navigation
fix(errors): stop treating Codex HTML challenge pages as DNS failures - #67704
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves upstream error detection/formatting so that standalone CDN/Cloudflare HTML challenge pages (not prefixed by an HTTP status line) are recognized and presented as an upstream HTML/CDN block instead of being misclassified as local DNS failures.
Changes:
- Extend
isCloudflareOrHtmlErrorPageto detect standalone Cloudflare/CDN challenge HTML using content hints (even without a leading status line). - Prevent transport error copy from treating HTML challenge pages as DNS failures by bypassing transport-classification when the payload is an HTML/CDN block page.
- Add regression tests covering standalone challenge HTML detection and user-facing formatting output.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/shared/assistant-error-format.ts | Adds standalone HTML challenge detection and formats these into the existing “upstream HTML/CDN block” UI copy. |
| src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts | Avoids transport-layer DNS classification when the raw error is actually an HTML/CDN block page. |
| src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts | Adds a regression test for standalone Cloudflare challenge HTML detection. |
| src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts | Adds regression coverage ensuring standalone challenge HTML is formatted as upstream HTML/CDN block (not DNS). |
| "This usually means a CDN or gateway (e.g. Cloudflare) blocked the request. " + | ||
| "Retry in a moment or check provider status." | ||
| ); | ||
| } |
Greptile SummaryThis PR fixes a misclassification where Cloudflare HTML challenge pages (e.g., Codex OAuth failures returning The fix adds a standalone HTML detection branch to Confidence Score: 5/5Safe to merge — all remaining findings are P2 style suggestions that do not affect correctness. The logic is correct and well-tested with both a regression case (HTML with dns-prefetch is not misclassified) and a control case (real ENOTFOUND still maps to DNS message). The standalone HTML detection gate is narrow (requires HTML open + close tags plus a Cloudflare/CDN hint keyword), making false positives unlikely in practice. The only finding is a P2 double-regex call that could be cached. No files require special attention.
|
|
Addressing the Copilot perf nit in 02500aca43: |
02500ac to
cbdc309
Compare
Cloudflare challenge pages from chatgpt.com/backend-api can arrive as raw HTML without an HTTP status prefix. The transport sanitizer scanned for generic "dns" substrings before HTML detection, so these pages could surface as DNS lookup failures instead of the existing HTML/CDN block message. Constraint: Must preserve DNS transport classification for real ENOTFOUND/getaddrinfo failures Rejected: Treat every bare HTML document as an upstream HTML error | too broad for arbitrary model text/errors Confidence: high Scope-risk: narrow Directive: Keep standalone HTML challenge detection ahead of generic transport keyword matching so CDN block pages do not regress into DNS copy Tested: oxfmt --check on changed files; targeted node --import tsx verification for standalone Cloudflare HTML classification and DNS control case Not-tested: Full Vitest shard run in this environment
The HTML challenge fix already keeps standalone CDN block pages out of the DNS transport path. This follow-up caches the HTML classification so status-prefixed non-HTML failures do not pay for the same scan twice and the control flow stays simpler. Constraint: Keep behavior identical for both status-prefixed HTML pages and standalone HTML challenge pages Rejected: Inline the helper into the status branch only | would duplicate the standalone HTML branch logic Confidence: high Scope-risk: narrow Directive: If this formatter grows more branches, keep a single HTML classification result and reuse it through the decision tree Tested: oxfmt --check src/shared/assistant-error-format.ts Tested: node scripts/test-projects.mjs src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts src/agents/pi-embedded-helpers.isbillingerrormessage.test.ts
cbdc309 to
cd61f12
Compare
|
Landed via temp rebase onto main.
Thanks @chris-yyau! |
Summary
dnssubstringsWhy
Codex OAuth requests can fail with a raw HTML challenge page from
chatgpt.com/backend-api(for example,Enable JavaScript and cookies to continue). Today those pages can be mislabeled asLLM request failed: DNS lookup for the provider endpoint failed.That makes the failure mode look like a local network problem even though the real issue is an upstream HTML/CDN block page.
Verification
oxfmt --check src/shared/assistant-error-format.ts src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts src/agents/pi-embedded-helpers.isbillingerrormessage.test.tsnode scripts/test-projects.mjs src/agents/pi-embedded-helpers.formatassistanterrortext.test.ts src/agents/pi-embedded-helpers.isbillingerrormessage.test.tsnode --import tsxverification for: