Skip to content

[FIX] Show malformed XML response details#1727

Open
anisha-04 wants to merge 1 commit into
openml:mainfrom
anisha-04:fix/show-invalid-xml-error
Open

[FIX] Show malformed XML response details#1727
anisha-04 wants to merge 1 commit into
openml:mainfrom
anisha-04:fix/show-invalid-xml-error

Conversation

@anisha-04

Copy link
Copy Markdown

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.

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

1 participant