Files
coder/coderd/x
Cian Johnston 5d2a69d85a fix(coderd/x/chatd/chaterror): extract plain-text provider error bodies (#27597)
Follows up #27538.

Fixes an issue where `chaterror` would not classify a plain-text
aibridge budget error 403 as ChatErrorKindUsageLimit.

Root cause: Anthropic adapter drops the body from
`ProviderError.Message`, and `providerErrorResponseMessage` extracted
only JSON.

- Parses the dumped response with `http.ReadResponse` (strips headers,
de-chunks, leaves non-dump payloads like Google's raw messages whole).
- When JSON extraction yields nothing, falls back to the trimmed first
line of the body.
- Falls back on `Content-Type: text/plain` only, and never on valid JSON
as `Detail` is user-facing.
- Adds an end-to-end regression test that Anthropic-shaped 403 budget
error → `usage_limit`, not retryable (was `auth`).
- Adds table-driven test cases: HTML skipped, whitespace skipped,
first-line-only, JSON-without-message, chunked, Google raw message.

---

> Generated by Coder Agents on behalf of @johnstcn.
2026-07-29 10:38:15 +01:00
..