Repository navigation
ROB: Do not crash when the XObject resources are not a dictionary - #4030
Merged
stefan6419846 merged 4 commits intoAug 31, 2026
Merged
Conversation
_get_ids_image reads /XObject off the page resources and iterates it, so a file where that entry holds a number, a string or an array raised 'TypeError: NumberObject object is not iterable' from page.images. The lookup already carried a type: ignore, and the function returns an empty list when the entry is missing, so one it cannot walk takes the same path.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4030 +/- ##
=======================================
Coverage 98.02% 98.03%
=======================================
Files 57 57
Lines 11165 11210 +45
Branches 2099 2110 +11
=======================================
+ Hits 10945 10990 +45
Misses 123 123
Partials 97 97 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
requested changes
Aug 29, 2026
The lookup only needs to silence the index error on PdfObject, so the bare ignore is replaced with type: ignore[index]. The separate entry variable also goes, since the isinstance check narrows the original one.
Contributor
Author
|
Done, it is type: ignore[index] now - that was the only error it was hiding. I also dropped the extra variable I had added, since the isinstance check narrows the original one. |
stefan6419846
requested changes
Aug 30, 2026
stefan6419846
approved these changes
Aug 31, 2026
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.
If a page has an /XObject entry that is not a dictionary, listing the images crashes. _get_ids_image reads /XObject from the page resources and loops over it straight away.
The line that reads it already had a type: ignore on it, so the type was known not to be guaranteed. The function returns an empty list when there is no /XObject at all, so now one it cannot read does the same.
Pages with real images are not affected — I checked against the files in resources/.