From 50180aaa14b84105298731404cae10427fc0b0d3 Mon Sep 17 00:00:00 2001 From: busya Date: Fri, 5 Jun 2026 12:10:20 +0300 Subject: [PATCH] 035: fix httpx.Response.ok -> httpx.Response.is_success in LLM client httpx.Response does not have .ok attribute (that's requests.Response). Async migration missed this: _llm_async_http.py used response.ok in two places, causing 502 errors when LLM API responded. Fix: response.ok -> response.is_success --- backend/src/plugins/translate/_llm_async_http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/plugins/translate/_llm_async_http.py b/backend/src/plugins/translate/_llm_async_http.py index 3861009a..6389acb7 100644 --- a/backend/src/plugins/translate/_llm_async_http.py +++ b/backend/src/plugins/translate/_llm_async_http.py @@ -117,7 +117,7 @@ async def call_openai_compatible( response, response_text = await _do_http_request(url, headers, payload) await _handle_response_format_fallback(response, response_text, payload, url, headers) - if not response.ok: + if not response.is_success: logger.explore( f"LLM API error status={response.status_code} " f"model={payload.get('model')} " @@ -225,7 +225,7 @@ async def _handle_response_format_fallback( """Handle 400 errors from structured_outputs not being supported.""" _patterns = ("response_format", "structured_outputs", "structured", "json_object") if ( - not response.ok + not response.is_success and response.status_code == 400 and any(p in (response_text or "").lower() for p in _patterns) ):