fix(ocr): round-5 review nits — empty-pages failure, comments, test cleanup

Round 5 review (PR #910), all nits, no blockers:
- _result_from_success: a succeeded job with `pages=[]` (empty list, not just a
  missing key) is now a per-document failure ("no pages returned") instead of a
  silent 0-chunk success. Test added.
- Comment the deadline-expiry path: the gateway-side job isn't cancelled (no
  cancel endpoint at this layer) — it's reaped by the gateway file purge; we just
  stop polling it.
- Drop the vestigial status="pending" from the BatchOcrJob test fakes (the column
  was removed in round 4; BatchPollResult.status fakes are untouched).

1653 unit tests pass; ruff + ty green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Chris Coutinho
2026-06-15 11:12:42 +02:00
co-authored by Claude Opus 4.8
parent 232684e881
commit bb08245c91
4 changed files with 25 additions and 8 deletions
+9
View File
@@ -140,6 +140,15 @@ async def test_poll_succeeded_with_per_document_error_is_failed(monkeypatch):
assert result.is_failed and result.error == "bad page"
async def test_poll_succeeded_empty_pages_is_failed(monkeypatch):
# A succeeded job that produced zero pages is a per-document failure, not a
# silent 0-chunk success.
body = {"status": "succeeded", "results": [{"custom_id": "d", "pages": []}]}
_patch_transport(monkeypatch, lambda r: httpx.Response(200, json=body))
result = await gbc.GatewayBatchOcrClient("https://gw", "m").poll("mistral/j")
assert result.is_failed and result.error == "no pages returned"
async def test_poll_succeeded_no_results_is_failed(monkeypatch):
_patch_transport(
monkeypatch,