Skip to content

ROB: Do not crash on an outline node that is not a dictionary - #4018

Merged
stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:outline-non-dictionary-node
Aug 27, 2026
Merged

stefan6419846 merged 2 commits into
py-pdf:mainfrom
RavSinghChandan:outline-non-dictionary-node

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

The outline walk casts /First to a DictionaryObject and subscripts it, so a file where that entry holds a number, a string or an array brings down the whole read:

>>> reader.outline
TypeError: 'NumberObject' object is not subscriptable

The same loop already warns and stops on a cycle, so a node it cannot walk is reported the same way and the read returns what it has. Valid outlines 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.01%. Comparing base (39565fe) to head (cd8e9fb).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4018   +/-   ##
=======================================
  Coverage   98.00%   98.01%           
=======================================
  Files          57       57           
  Lines       11154    11157    +3     
  Branches     2095     2096    +1     
=======================================
+ Hits        10932    10935    +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.

@stefan6419846 stefan6419846 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added an inline comment.

Please note that we generally appreciate robustness fixes like these. However, we should avoid having a large number of such similar PRs being worked on in parallel. Given the current number of such PRs, a significant amount of my time is currently going into reviewing them, which makes it harder for me to look into other reported issues and important blockers.

I hope you understand, and that you are able to keep the number of parallel changes at a manageable level. I would prefer not to introduce a strict limit on the number of parallel PRs per contributor, thus I appreciate your help in keeping this manageable.

Additionally, given the relatively large number of previously unreported issues and multiple PRs appearing in close succession, please make sure to follow our contribution guidelines regarding AI usage. I am not trying to imply that you have ignored these guidelines, but some aspects of the current changes raised the question for me, so I would like to make sure we are aligned on this point as well.

Comment thread tests/test_doc_common.py Resolved
@RavSinghChandan
RavSinghChandan force-pushed the outline-non-dictionary-node branch from dbdc5be to 6dde16d Compare August 27, 2026 02:33
@RavSinghChandan

Copy link
Copy Markdown
Contributor Author

Added the IDs.

@RavSinghChandan

Copy link
Copy Markdown
Contributor Author
  1. Use AI to help identify and fix issues.
  2. Personally review and test everything before opening a PR.
  3. I’ll mention the AI tool and model used in the PR description.
  4. I’ll limit my contributions to 1–2 PRs at a time.

@RavSinghChandan
RavSinghChandan force-pushed the outline-non-dictionary-node branch from 6dde16d to 523b75d Compare August 27, 2026 12:12
The outline walk casts /First to a DictionaryObject and subscripts it, so a
file where that entry holds a number, a string or an array raised 'TypeError:
NumberObject object is not subscriptable' from reader.outline.

The same loop already warns and stops on a cycle, so an unusable node is
reported the same way and the outline read returns what it has.
@RavSinghChandan
RavSinghChandan force-pushed the outline-non-dictionary-node branch from 0e60414 to fd113dd Compare August 27, 2026 14:40
@stefan6419846
stefan6419846 merged commit 58fd80a into py-pdf:main Aug 27, 2026
20 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