This was written agentically; verify its assertions:
The optional real-OCR integration test cannot recover PART 1 from an image-only PDF. The renderer passes a Node Buffer into unpdf/PDF.js, which rejects it with Please provide binary data as Uint8Array, rather than Buffer. The parser catches this and returns pdf-ocr-unusable, leaving no recovered PART heading.
Evidence
Discovered while validating dependency PR #681. The same focused test fails on the pre-update main checkout at 660cb7347ac7bcea06dc4c10bee6ad824d8c854a (canvas 1.0.8, Zod 4.5.4) and PR head 55e075c45171fa906416e20af22de8b047c09961 (canvas 1.0.9, Zod 4.6.2). Both use pdfjs-dist 6.3.289 / unpdf 1.8.1. This is not a regression introduced by #681. Direct calls to recognizePdfPages expose the same nested cause on both dependency sets. Native canvas 1.0.9 font rendering and PNG encode/decode pass independently.
Run against a migrated and seeded disposable PostgreSQL database:
NODE_ENV=test SPECR_OCR_E2E=1 pnpm exec vitest run --project integration src/parser/pdf/ocr.integration.test.ts
Set DATABASE_URL to that test database. Failure: src/parser/pdf/ocr.integration.test.ts:107, the recovered first PART text is undefined.
Root cause
src/parser/pdf/ocr.ts function pdfData returns the input Buffer unchanged, despite its Uint8Array return type. defaultRenderPageAsImage forwards it through unpdf.renderPageAsImage to PDF.js getDocument; PDF.js explicitly rejects Buffer objects. The existing text extractor instead supplies owned ArrayBuffer data.
Acceptance criteria
- Supply supported binary data at the real OCR rendering boundary while preserving caller ownership.
- Pin this failure with a regression test that runs in normal CI, in addition to the opt-in real OCR test.
- The real image-only PDF test recovers GENERAL and reports
pdf-ocr-applied.
- Preserve error redaction and existing OCR timeouts/offline behavior.
Priority: medium; area: PDF parser/OCR. Tracked separately from dependency maintenance.
🤖 Co-authored by Codex.
This was written agentically; verify its assertions:
The optional real-OCR integration test cannot recover PART 1 from an image-only PDF. The renderer passes a Node Buffer into unpdf/PDF.js, which rejects it with
Please provide binary data as Uint8Array, rather than Buffer.The parser catches this and returnspdf-ocr-unusable, leaving no recovered PART heading.Evidence
Discovered while validating dependency PR #681. The same focused test fails on the pre-update main checkout at
660cb7347ac7bcea06dc4c10bee6ad824d8c854a(canvas 1.0.8, Zod 4.5.4) and PR head55e075c45171fa906416e20af22de8b047c09961(canvas 1.0.9, Zod 4.6.2). Both use pdfjs-dist 6.3.289 / unpdf 1.8.1. This is not a regression introduced by #681. Direct calls torecognizePdfPagesexpose the same nested cause on both dependency sets. Native canvas 1.0.9 font rendering and PNG encode/decode pass independently.Run against a migrated and seeded disposable PostgreSQL database:
NODE_ENV=test SPECR_OCR_E2E=1 pnpm exec vitest run --project integration src/parser/pdf/ocr.integration.test.tsSet DATABASE_URL to that test database. Failure:
src/parser/pdf/ocr.integration.test.ts:107, the recovered first PART text is undefined.Root cause
src/parser/pdf/ocr.tsfunctionpdfDatareturns the input Buffer unchanged, despite its Uint8Array return type.defaultRenderPageAsImageforwards it throughunpdf.renderPageAsImageto PDF.jsgetDocument; PDF.js explicitly rejects Buffer objects. The existing text extractor instead supplies owned ArrayBuffer data.Acceptance criteria
pdf-ocr-applied.Priority: medium; area: PDF parser/OCR. Tracked separately from dependency maintenance.
🤖 Co-authored by Codex.