Unexpected KeyError when using scrub with fitz_new (original) (raw)

Describe the bug (mandatory)

The following script causes a KeyError when applied to the attached PDF: bug.pdf

import fitz_new as fitz pdf = fitz.open("bug.pdf") pdf.scrub()

The exception received on the last line is:

./venv/lib64/python3.12/site-packages/fitz_new/__init__.py:54:exception_info: exception_info:
Traceback (most recent call last):
  File "./venv/lib64/python3.12/site-packages/fitz_new/__init__.py", line 8433, in finished
    linkobj = self._annot_refs[linkid]
              ~~~~~~~~~~~~~~~~^^^^^^^^
  File "/usr/lib64/python3.12/weakref.py", line 136, in __getitem__
    o = self.data[key]()
        ~~~~~~~~~^^^^^
KeyError: ''

The trigger seems to be an email URL in the PDF document bug.pdf.

To Reproduce (mandatory)

See above

Expected behavior (optional)

scrub should run without KeyError, I assume.

Screenshots (optional)

Not applicable

Your configuration (mandatory)