Skip to content

fix: retry PDF shard split after source object out of range - #325

Merged
suguanYang merged 1 commit into
mainfrom
fix/wangbinqi/pdf-split-object-out-of-range
Aug 24, 2026
Merged

fix: retry PDF shard split after source object out of range#325
suguanYang merged 1 commit into
mainfrom
fix/wangbinqi/pdf-split-object-out-of-range

Conversation

@suguanYang

@suguanYang suguanYang commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Catch only PyMuPDF RuntimeError: source object number out of range during pdf.split insert_pdf.
  • Rewrite the source once with garbage=4 and retry the shard split; all other PDF errors still fail as before.
  • This unblocks incremental Quartz/AppendMode PDFs that Chrome can open but PyMuPDF cannot copy objects from (prod: Exercise_Prescription_in_Cardiac_Rehabilitation.pdf / job_e6d257afa2ae).

Test plan

  • uv run pytest apps/worker/tests/unit/test_pdf_split_object_out_of_range.py
  • Full 196-page local split of the customer PDF succeeds after one rewrite
  • Confirm a normal PDF still splits without writing _rewritten_source.pdf
  • After deploy, re-run job_e6d257afa2ae / Exercise_Prescription_in_Cardiac_Rehabilitation.pdf and confirm pdf.split no longer fails with code=4

Incremental Quartz PDFs can be probed but fail insert_pdf when copying xrefs. Catch only that error, rewrite a clean copy once, and retry the split.

Co-authored-by: Cursor <cursoragent@cursor.com>
@suguanYang
suguanYang merged commit 2c8ab4f into main Aug 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant