Skip to content

ROB: Do not crash on a form field entry that is not a dictionary - #4031

Merged
stefan6419846 merged 3 commits into
py-pdf:mainfrom
RavSinghChandan:field-entry-not-a-dictionary
Aug 30, 2026
Merged

stefan6419846 merged 3 commits into
py-pdf:mainfrom
RavSinghChandan:field-entry-not-a-dictionary

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

If the /Fields array contains something that is not a dictionary, reading the form fields crashes. _build_field checks for /T and /TM inside each entry.

Now an entry that cannot be read is logged and skipped, so the other fields in the form are still returned instead of losing all of them.

_build_field tests /T and /TM membership on whatever the /Fields array holds,
so an entry that is a number, a string or an array raised 'TypeError: argument
of type NumberObject is not iterable' from reader.get_fields().

An entry it cannot read is reported and skipped, so the remaining fields are
still returned.
@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.03%. Comparing base (b17dee7) to head (0b714f4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4031   +/-   ##
=======================================
  Coverage   98.02%   98.03%           
=======================================
  Files          57       57           
  Lines       11165    11168    +3     
  Branches     2099     2100    +1     
=======================================
+ Hits        10945    10948    +3     
  Misses        123      123           
  Partials       97       97           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread tests/test_doc_common.py Resolved
get_fields is already exercised against a real form elsewhere in the suite,
so the added test covered nothing new.
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

You are right, get_fields is already covered against a real form elsewhere. Removed it.

Comment thread tests/test_doc_common.py Resolved
@stefan6419846
stefan6419846 merged commit 07d5569 into py-pdf:main Aug 30, 2026
11 of 18 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