Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
Drop legacy detail error handling
jinzhenj2e192d271bd5
diff --git a/mineru/parser/api_client.py b/mineru/parser/api_client.pyindex b7b915b9..5091ad6d 100644--- a/mineru/parser/api_client.py+++ b/mineru/parser/api_client.py@@ -144,15 +144,6 @@ class MinerUApiParser(DocumentParser):param=str(err["param"]) if err.get("param") is not None else None,)raise _V1APIError("unknown", str(err))- if "detail" in data and isinstance(data["detail"], dict) and "error" in data["detail"]:- err = data["detail"]["error"]- if isinstance(err, dict):- raise _V1APIError(- str(err.get("code") or "unknown"),- str(err.get("message") or err),- param=str(err["param"]) if err.get("param") is not None else None,- )- raise _V1APIError("unknown", str(err))return data# ── upload ───────────────────────────────────────────────────────@@ -545,11 +536,6 @@ def _structured_error(data: dict[str, Any]) -> dict[str, Any] | None:error = data.get("error")if isinstance(error, dict):return error- detail = data.get("detail")- if isinstance(detail, dict):- detail_error = detail.get("error")- if isinstance(detail_error, dict):- return detail_errorreturn Nonediff --git a/tests/unittest/test_parser_api_contract.py b/tests/unittest/test_parser_api_contract.pyindex 07743ef3..487af2db 100644--- a/tests/unittest/test_parser_api_contract.py+++ b/tests/unittest/test_parser_api_contract.py@@ -128,6 +128,28 @@ def test_api_client_preserves_structured_error_body_on_http_error() -> None:assert exc_info.value.param == "api_key"+def test_api_client_ignores_legacy_detail_error_envelope() -> None:+ response = _FakeResponse(+ 400,+ {+ "detail": {+ "error": {+ "type": "invalid_request_error",+ "code": "invalid_request",+ "message": "legacy detail envelope",+ }+ }+ },+ text='{"detail":{"error":{"code":"invalid_request"}}}',+ )++ with pytest.raises(api_client._V1APIError) as exc_info:+ MinerUApiParser._check(response)++ assert exc_info.value.code == "http_error"+ assert exc_info.value.message.startswith("HTTP 400:")++def test_api_client_downloads_image_sidecars_and_preserves_pdf_mapping(monkeypatch: pytest.MonkeyPatch) -> None:parser = MinerUApiParser(api_url="http://localhost:8000", tier="standard")middle_json = {