Skip to content

ROB: Do not crash when the AcroForm fields entry is not an array - #4019

Merged
stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:acroform-fields-not-array
Aug 27, 2026
Merged

stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:acroform-fields-not-array

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

get_fields casts /Fields to an ArrayObject and iterates it, so a file where that entry holds a number, a string or a dictionary raises:

>>> reader.get_fields()
TypeError: 'NumberObject' object is not iterable

The reference is resolved first, since /Fields is usually indirect, and an entry that cannot be walked is reported the same way as the other malformed structures the reader tolerates. Real forms are untouched.

Reverting the change fails the three new tests

@codecov

codecov Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.00%. Comparing base (d85ef0f) to head (238d831).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4019   +/-   ##
=======================================
  Coverage   98.00%   98.00%           
=======================================
  Files          57       57           
  Lines       11136    11139    +3     
  Branches     2090     2091    +1     
=======================================
+ Hits        10914    10917    +3     
  Misses        124      124           
  Partials       98       98           

☔ 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.

@RavSinghChandan
RavSinghChandan force-pushed the acroform-fields-not-array branch from a6c4008 to 11be471 Compare August 26, 2026 10:09
Comment thread tests/test_doc_common.py Resolved
get_fields casts /Fields to an ArrayObject and iterates it, so a file where
that entry holds a number, a string or a dictionary raised 'TypeError:
NumberObject object is not iterable'.

The reference is resolved first, since /Fields is usually indirect, and an
entry that cannot be walked is reported the same way as the other malformed
structures the reader tolerates.
@RavSinghChandan
RavSinghChandan force-pushed the acroform-fields-not-array branch from 11be471 to 238d831 Compare August 27, 2026 02:34
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Added the IDs.

@stefan6419846
stefan6419846 merged commit 9623c3b into py-pdf:main Aug 27, 2026
54 of 76 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