Repository navigation
[FIX] Show malformed XML response details - #1727
Conversation
PGijsbers
left a comment
There was a problem hiding this comment.
Thank you for your contribution! I simplified the flow of the method a bit and added additional checks for parsing "successful" responses since they are unfortunately not always valid XML.
Sorry for not taking the time to go through a review/mentoring cycle. Unfortunately I do not currently have the bandwidth to do that for many PRs in parallel, so I am prioritizing getting your changes in and getting the repository to a maintainable state. Thanks for your understanding!
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1727 +/- ##
==========================================
- Coverage 53.83% 53.68% -0.16%
==========================================
Files 63 63
Lines 5240 5251 +11
==========================================
- Hits 2821 2819 -2
- Misses 2419 2432 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Metadata
Details
What does this PR implement/fix?
When an unsuccessful GET response contains malformed XML, the HTTP client now preserves its existing retry behavior and ultimately raises
OpenMLServerErrorwith the request URL, HTTP status, and unparsed response body. The original XML parser exception remains attached as the exception cause.A deterministic regression test mocks a malformed XML response and verifies the complete user-facing error.
Root cause
HTTPClient._validate_response()returned the rawExpatErrorfor malformed GET responses. After retries were exhausted,_request()raised that parser error directly, so the response details needed to diagnose a server-side failure were lost. Non-GET requests already produced a usefulOpenMLServerError.Testing
.venv/bin/pytest -q tests/test_api/test_http.py— 13 passed.venv/bin/pytest -q tests/test_api/test_http.py -m 'not test_server'— 4 passed, 9 deselected.venv/bin/pre-commit run --files openml/_api/clients/http.py tests/test_api/test_http.py— all configured hooks passed (Ruff, Ruff format, mypy, and repository checks)git diff --check— passedDocumentation and compatibility
No documentation change is required because this does not alter the public API. Successful responses and valid server error responses are unchanged. Malformed GET error responses continue to be retried, but now fail with the existing OpenML exception type and useful diagnostic context.
Limitations
The raw response body is included only for malformed error responses, matching the existing non-GET behavior. This change does not alter retry policy or attempt to repair invalid server XML.