Repository navigation
fix(docparser): recover malformed PDFs with the builtin reader - #4716
Merged
lyingbug merged 1 commit intoOct 26, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
malformederror from AnyDoc 0.2.4, with compatibility for the earlier invalid-structure message, and hand the original request bytes to the builtin reader. Recordanydoc_fallback=invalid_structureand 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 AnyDocReadrouting 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.