Skip to content

Commit f78b32f

Browse files
authored
Merge pull request #585 from okurz/feature/openqa_investigate_llm
feat(openqa-llm-investigate): include host and model in LLM API error messages
2 parents f8d00a9 + 649ab17 commit f78b32f

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

openqa-llm-investigate

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ Provide exactly 3 sentences answering:
230230
)
231231
sys.exit(1)
232232
except httpx.HTTPStatusError as e:
233-
log.error("LLM API returned an error status: %s. Detail: %s", e.response.status_code, e.response.text)
233+
log.error("LLM API %s (%s) status %d: %s", llm_url, llm_model, e.response.status_code, e.response.text)
234234
sys.exit(1)
235235
except Exception as e:
236-
log.error("LLM API request failed: %s", e)
236+
log.error("LLM API %s (%s) failed: %s", llm_url, llm_model, e)
237237
sys.exit(1)
238238

239239
# Print the job URL to stdout ONLY if BISECT: YES is recommended

tests/test_openqa_llm_investigate.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,27 @@ def test_investigate_cmd_connection_error(mocker: MockerFixture) -> None:
230230
assert "Could not connect to LLM server" in mock_log.error.call_args[0][0]
231231

232232

233+
def test_investigate_cmd_http_status_error(mocker: MockerFixture) -> None:
234+
mock_log = mocker.patch("llm_investigate.log")
235+
client = setup_mock_client(mocker)
236+
mock_resp = Mock()
237+
mock_resp.status_code = 500
238+
mock_resp.text = "Internal Server Error"
239+
client.post.side_effect = httpx.HTTPStatusError("error", request=Mock(), response=mock_resp)
240+
241+
with pytest.raises(SystemExit) as exc:
242+
llm_investigate.investigate("123")
243+
244+
assert exc.value.code == 1
245+
mock_log.error.assert_called_once()
246+
error_msg = mock_log.error.call_args[0][0]
247+
assert error_msg == "LLM API %s (%s) status %d: %s"
248+
assert mock_log.error.call_args[0][1] == "http://localhost:8080/v1/chat/completions"
249+
assert mock_log.error.call_args[0][2] == "gemma-4-26B-A4B-it"
250+
assert mock_log.error.call_args[0][3] == 500
251+
assert mock_log.error.call_args[0][4] == "Internal Server Error"
252+
253+
233254
def test_investigate_logging_levels(mocker: MockerFixture) -> None:
234255
mock_basic_config = mocker.patch("llm_investigate.logging.basicConfig")
235256
mocker.patch("llm_investigate.httpx.Client")

0 commit comments

Comments
 (0)