Commit Graph

7 Commits

Author SHA1 Message Date
Logan Ye
ef7c528c8a fix(agents): recognize flat JSON billing payloads and snake_case error codes (#74188)
* fix(agents): recognize flat JSON billing payloads and snake_case error codes

Two independent fixes for billing error detection:

1. isErrorPayloadObject/parseApiErrorInfo now recognize flat JSON like
   {"error":"string_code","message":"..."} where error is a string code
   at the top level, not just nested {"error":{"type":"...","message":"..."}}
   envelopes.

2. isBillingErrorMessage now matches "insufficient_balance" (underscore)
   and "Insufficient MBT balance" (one word between insufficient/balance)
   via two new patterns in the billing pattern list.

Together these prevent raw JSON from leaking to user-facing chat when
providers return 402-style flat payloads.

Fixes #74079

* fix(agents): remove redundant billing pattern and fix misleading regex comment
2026-04-29 07:15:45 -04:00
Chris Yau
59caf03d67 Avoid rescanning HTML challenge pages during error formatting
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
2026-04-16 12:47:12 -07:00
Chris Yau
36dd58ac2a Prevent Codex HTML challenge pages from looking like DNS failures
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
2026-04-16 12:47:12 -07:00
nikus-pan
bef4fa55f5 fix(model-fallback): add HTTP 410 to failover reason classification (#55201)
Merged via squash.

Prepared head SHA: 9c1780b739
Co-authored-by: nikus-pan <71585761+nikus-pan@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
2026-03-28 14:03:20 +03:00
助爪
b1c982bb2d fix(agents): fail over and sanitize Codex server_error payloads (#42892)
Merged via squash.

Prepared head SHA: 6db9a5f02d
Co-authored-by: xaeon2026 <264572156+xaeon2026@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
2026-03-27 16:51:39 +03:00
Vincent Koc
d3ffa1e4e7 refactor(errors): share api error payload parsing 2026-03-20 09:30:33 -07:00
Vincent Koc
397b0d85f5 fix(tui): split assistant error formatting seam 2026-03-20 00:06:12 -07:00