Skip to content

fix: map JSONL result HTTP errors to SDK errors - #18316

Open
tandede wants to merge 1 commit into
PaddlePaddle:mainfrom
tandede:fix/api-result-http-errors
Open

fix: map JSONL result HTTP errors to SDK errors#18316
tandede wants to merge 1 commit into
PaddlePaddle:mainfrom
tandede:fix/api-result-http-errors

Conversation

@tandede

@tandede tandede commented Aug 19, 2026

Copy link
Copy Markdown

Problem

The Python SDK documents that its errors inherit from PaddleOCRAPIError. Most synchronous HTTP paths enforce that contract through the shared response mapper, but HTTPClient.fetch_jsonl() calls requests.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 catching PaddleOCRAPIError cannot 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 typed APIError, without changing successful JSONL parsing.

The regression test serves a local 404 response with a Result expired message and verifies that fetch_jsonl() raises APIError with both the 404 status and response message.

Validation

  • python -m pytest -q tests/api_client — 27 passed
  • pre-commit run --files paddleocr/_api_client/_http.py tests/api_client/test_http.py — all hooks passed

@CLAassistant

CLAassistant commented Aug 19, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@tandede
tandede marked this pull request as ready for review August 19, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants