[FIX] Show malformed XML response details#1727
Open
anisha-04 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.