Bound model catalog decode errors and classify request timeouts (#45928)

## Why

Model catalog decode errors can include the full response body and payload values from deserialization errors. Catalog request deadlines also report a generic timeout instead of a request timeout.

## What changed

- Report only the JSON error category, line, column, and response byte count when model catalog decoding fails.
- Return `CodexErr::RequestTimeout` when the model catalog refresh deadline expires.

## Testing

Add regression tests for invalid response shapes, large payload values, malformed and truncated JSON, and a delayed catalog response that must return `RequestTimeout`.

GitOrigin-RevId: 6fe5111a3e3b113d79942b3c213f8e94d773eb5a
This commit is contained in:
jif
2026-09-16 11:46:37 +00:00
committed by copyberry
parent 8f38d5a877
commit 977193486d
4 changed files with 101 additions and 3 deletions
+5 -2
View File
@@ -59,8 +59,11 @@ impl<T: HttpTransport> ModelsClient<T> {
let ModelsResponse { models } =
serde_json::from_slice::<ModelsResponse>(&body).map_err(|e| {
ApiError::Stream(format!(
"failed to decode models response: {e}; body: {}",
String::from_utf8_lossy(&body)
"failed to decode models response: {:?} at line {} column {} (body: {} bytes)",
e.classify(),
e.line(),
e.column(),
body.len()
))
})?;