Skip to content

fix(docparser): recover malformed PDFs with the builtin reader - #4716

Merged
lyingbug merged 1 commit into
Tencent:mainfrom
acse-bq23:work/upstream-pdf-fallback-20261026
Oct 26, 2026
Merged

lyingbug merged 1 commit into
Tencent:mainfrom
acse-bq23:work/upstream-pdf-fallback-20261026

Conversation

@acse-bq23

Copy link
Copy Markdown
Contributor

Some PDFs rejected by AnyDoc's structural parser remain readable by the builtin PDF engine. The reader currently returns that conversion error instead of trying its configured fallback.

Recognize the typed malformed error from AnyDoc 0.2.4, with compatibility for the earlier invalid-structure message, and hand the original request bytes to the builtin reader. Record anydoc_fallback=invalid_structure and preserve the fallback's page/image classification. Existing scanned-PDF OCR routing is retained; encryption, parser limits, I/O and unavailable-engine failures keep their existing handling.

Validation against main e1f9a6166: built and linked the pinned AnyDoc 0.2.4 archive on Linux; the parser-package race suite, linked and unlinked targeted regressions, go vet, and diff-scoped golangci-lint v2.12.2 pass. Tests cover wrapped/typed errors, typed nil, real AnyDoc Read routing with a recording fallback, original-request preservation, page metadata, disconnected/nil/error fallbacks, and cancellation/resource-limit error identity. No application deployment or external model call was performed.

Classify typed anydoc malformed errors and preserve builtin page metadata on fallback. Keep encryption, resource limits, I/O errors and unavailable engines on their existing paths. Validation: linked and stub race tests, related parser suite, go vet and diff-scoped golangci-lint passed.
@lyingbug
lyingbug merged commit 52e4cf8 into Tencent:main Oct 26, 2026
5 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.

2 participants