Repository navigation
ROB: Do not crash when the font resources are not a dictionary - #4138
Merged
stefan6419846 merged 3 commits intoOct 3, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4138 +/- ##
==========================================
+ Coverage 98.10% 98.12% +0.01%
==========================================
Files 59 59
Lines 11563 11572 +9
Branches 2163 2161 -2
==========================================
+ Hits 11344 11355 +11
+ Misses 124 123 -1
+ Partials 95 94 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
stefan6419846
requested changes
Oct 3, 2026
stefan6419846
approved these changes
Oct 3, 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.
Reopening the fix from #4043, which I closed earlier to stay within one or two
open PRs. Same idea, with three gaps closed.
If a page's /Resources has a /Font entry that is not a dictionary (a number,
string or array), extract_text() fails with
TypeError: 'NumberObject' object is not iterable. It happens in plain mode and
in layout mode. A null /Font crashed the same way.
This adds _get_font_resources() next to _get_page_resources() and follows the
same pattern. Null or missing gives an empty dictionary with no warning. Any
other non-dictionary value logs "Font resources are not a dictionary" and gives
an empty dictionary. Both the plain and layout extraction paths now use it.
Compared to #4043: null is now treated as absent instead of malformed, the
layout-mode path is fixed too, and there is a test for the null case. The normal
path is already covered by test_extract_text__resources_is_a_dictionary.
The tests fail without the change and pass with it. Locally the only failures
are tests whose files are missing from tests/pdf_cache, and those fail the same
way on main.
Used Claude Code (Claude Opus 5.5) to help find and patch this; I reviewed and
tested the change.