fix: map JSONL result HTTP errors to SDK errors - #18316
Open
tandede wants to merge 1 commit into
Open
Conversation
tandede
marked this pull request as ready for review
August 19, 2026 11:29
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.
Problem
The Python SDK documents that its errors inherit from
PaddleOCRAPIError. Most synchronous HTTP paths enforce that contract through the shared response mapper, butHTTPClient.fetch_jsonl()callsrequests.Response.raise_for_status()directly.When a completed job's result URL is expired or object storage returns another non-2xx response, the method therefore leaks a raw
requests.HTTPError. Callers catchingPaddleOCRAPIErrorcannot handle that result-download failure consistently, and the behavior also differs from the asynchronous JSONL path.Fix
Route JSONL result response statuses through the existing
_raise_for_response()helper before parsing. This preserves the HTTP status and API message in the SDK's typedAPIError, without changing successful JSONL parsing.The regression test serves a local 404 response with a
Result expiredmessage and verifies thatfetch_jsonl()raisesAPIErrorwith both the 404 status and response message.Validation
python -m pytest -q tests/api_client— 27 passedpre-commit run --files paddleocr/_api_client/_http.py tests/api_client/test_http.py— all hooks passed