Skip to content

Reject oversized PDF renders before bitmap allocation#4345

Merged
CyMule merged 2 commits intomainfrom
guard-pdf-render-max-pixels
Apr 26, 2026
Merged

Reject oversized PDF renders before bitmap allocation#4345
CyMule merged 2 commits intomainfrom
guard-pdf-render-max-pixels

Conversation

@CyMule
Copy link
Copy Markdown
Contributor

@CyMule CyMule commented Apr 26, 2026

Summary

  • pass the configured PDF render pixel limit into unstructured-inference
  • map oversized PDF render failures to UnprocessableEntityError
  • add coverage for filename/file-object paths and render-limit error handling

Note

Medium Risk
Changes hi-res PDF inference/rendering behavior by enforcing a per-page pixel cap and remapping upstream render failures to UnprocessableEntityError, which could alter error surfaces for some PDFs. Dependency bump to unstructured-inference may also change model/render behavior across platforms.

Overview
Prevents OOM/unsafe rendering for hi-res PDFs by passing a new PDF_RENDER_MAX_PIXELS_PER_PAGE limit through to unstructured-inference during hi-res partitioning and PDF-to-image conversion.

When unstructured-inference raises PdfRenderTooLargeError, the code now converts it into an UnprocessableEntityError so oversized pages fail fast with a consistent “unprocessable document” error instead of attempting bitmap allocation.

Bumps the unstructured-inference dependency (and lockfile resolutions) and adds tests covering both filename/file-object paths and the new oversized-render error handling.

Reviewed by Cursor Bugbot for commit 8bae7e0. Bugbot is set up for automated code reviews on this repo. Configure here.

@CyMule CyMule marked this pull request as ready for review April 26, 2026 20:47
@CyMule CyMule added this pull request to the merge queue Apr 26, 2026
Merged via the queue into main with commit b909cf4 Apr 26, 2026
54 checks passed
@CyMule CyMule deleted the guard-pdf-render-max-pixels branch April 26, 2026 22:23
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.

2 participants