feat: record and expose terminal upstream interception errors (#26961)

Categorises the terminal error of a failed interception and persists it
on the interception record, then surfaces it on the AI Gateway API.

- Categorise into an enum (`bad_request`, `unauthorized`,
  `rate_limited`, `overloaded`, `server_error`, `unknown`), unwrapping
  the ResponseError envelope, the upstream Anthropic/OpenAI SDK errors,
  and key-pool exhaustion so blocking and streaming paths agree.
- Thread the type and raw message through the recorder dRPC into the
  `aibridge_interceptions` row (optional proto fields; NULL on success).
- Expose the error on the AI Gateway thread API from the root
  interception.

*This PR was produced by opencode (agent) using the `anthropic/claude-opus-4-8` model, under human direction and review.*
This commit is contained in:
Danny Kopping
2026-07-09 15:36:56 +02:00
committed by GitHub
parent 63497ee9d8
commit ef0b5585d5
34 changed files with 1212 additions and 322 deletions
+2
View File
@@ -240,6 +240,8 @@ Alias: also available at /api/v2/aibridge/sessions/{session_id} for backward com
"credential_hint": "string",
"credential_kind": "string",
"ended_at": "2019-08-24T14:15:22Z",
"error_message": "string",
"error_type": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"model": "string",
"prompt": "string",
+6
View File
@@ -697,6 +697,8 @@
"credential_hint": "string",
"credential_kind": "string",
"ended_at": "2019-08-24T14:15:22Z",
"error_message": "string",
"error_type": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"model": "string",
"prompt": "string",
@@ -836,6 +838,8 @@
"credential_hint": "string",
"credential_kind": "string",
"ended_at": "2019-08-24T14:15:22Z",
"error_message": "string",
"error_type": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"model": "string",
"prompt": "string",
@@ -864,6 +868,8 @@
| `credential_hint` | string | false | | |
| `credential_kind` | string | false | | |
| `ended_at` | string | false | | |
| `error_message` | string | false | | Error message is the raw terminal upstream error message from the root interception. Nil when the interception succeeded. |
| `error_type` | string | false | | Error type is the categorized terminal upstream error from the root interception, or nil when the interception succeeded. See the aibridge_interception_error_type enum for possible values. |
| `id` | string | false | | |
| `model` | string | false | | |
| `prompt` | string | false | | |