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:
co-authored by
Claude Opus 4.8
parent
232684e881
commit
bb08245c91
@@ -184,8 +184,13 @@ def _result_from_success(body: dict[str, Any]) -> BatchPollResult:
|
||||
error="batch job succeeded but returned no results",
|
||||
)
|
||||
item = results[0]
|
||||
if item.get("error") is not None or item.get("pages") is None:
|
||||
return BatchPollResult(status=_FAILED, pages=[], error=item.get("error"))
|
||||
# ``not item.get("pages")`` catches both a missing key AND an empty list:
|
||||
# a succeeded job that produced zero pages is a per-document failure (nothing
|
||||
# to index), not a silent 0-chunk success.
|
||||
if item.get("error") is not None or not item.get("pages"):
|
||||
return BatchPollResult(
|
||||
status=_FAILED, pages=[], error=item.get("error") or "no pages returned"
|
||||
)
|
||||
# Defensive on both fields (the page index falls back to position) so a
|
||||
# malformed page object degrades rather than raising KeyError mid-parse.
|
||||
pages = [
|
||||
|
||||
Reference in New Issue
Block a user