fix: detect HTML responses in streaming path

When a provider returns HTML (e.g., error page, wrong endpoint) instead
of JSON in an SSE stream, provide a clear error message instead of
hanging or failing with a cryptic parse error.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
TheArchitectit
2026-05-25 05:21:00 +00:00
committed by Independent Security Research
co-authored by Claude Opus 4.7
parent 453ab6421b
commit baa8d1ba6e
@@ -1588,6 +1588,7 @@ fn parse_sse_frame(
body: payload.chars().take(200).collect(),
retryable: false,
suggested_action: Some("verify the API endpoint URL is correct".to_string()),
retry_after: None,
});
}
serde_json::from_str::<ChatCompletionChunk>(&payload)