Skip to content

[FIX] Show malformed XML response details - #1727

Merged
PGijsbers merged 4 commits into
openml:mainfrom
anisha-04:fix/show-invalid-xml-error
Oct 10, 2026
Merged

PGijsbers merged 4 commits into
openml:mainfrom
anisha-04:fix/show-invalid-xml-error

Conversation

@anisha-04

Copy link
Copy Markdown
Contributor

Metadata

  • Reference Issue: Fixes Show invalid XML on ExpatError #986
  • New Tests Added: Yes
  • Documentation Updated: No
  • Change Log Entry: "Show the response status and body when server error XML is malformed"

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 OpenMLServerError with 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 raw ExpatError for 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 useful OpenMLServerError.

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 — passed

Documentation 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.

PGijsbers
PGijsbers previously approved these changes Oct 10, 2026
@PGijsbers
PGijsbers dismissed their stale review October 10, 2026 16:47

accept was accidental

@PGijsbers PGijsbers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.57143% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.68%. Comparing base (1349366) to head (6e52afd).

Files with missing lines Patch % Lines
openml/_api/resources/base/versions.py 4.54% 21 Missing ⚠️
openml/_api/clients/http.py 0.00% 6 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PGijsbers
PGijsbers merged commit f1655df into openml:main Oct 10, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show invalid XML on ExpatError

3 participants