censor/Censor
1
37
Fork
You've already forked Censor
3

bug: sometimes impossible to save redactions, potential data loss #198

Open
opened 2026年05月05日 16:14:36 +02:00 by mahlzahn · 0 comments

Description

Sometimes it is impossible to save redactions, which leads to potential data loss (at least the already performed redactions are lost)

Example files

  • samples_openpreserve/jhove-errors/PDF-HUL-35/143424271191706722106594310729442158189.pdf
  • samples_openpreserve/jhove-errors/PDF-HUL-35/A Defence of the New Tenseless Theory of Time.pdf
  • samples_openpreserve/pdf-handbuilt-test-corpus/T02-02_004_page-tree-non-existing-object-as-kid.pdf
  • samples_openpreserve/pdf-handbuilt-test-corpus/T02-03_006_page-object-missing.pdf

Logs

Traceback (most recent call last):
 File "/usr/share/censor/censor/pymupdf_helpers.py", line 23, in clean_page
 mupdf_page.clean_contents(sanitize=False)
 ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
 File "/usr/lib/python3.14/site-packages/pymupdf/__init__.py", line 10870, in clean_contents
 mupdf.pdf_filter_page_contents( page.doc(), page, filter_)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/lib/python3.14/site-packages/mupdf/__init__.py", line 56523, in pdf_filter_page_contents
 return _mupdf.pdf_filter_page_contents(doc, page, options)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
mupdf.FzErrorArgument: code=4: not a dict (null)

and

WARNING: Saving Document Failed: code=4: not a dict (null)
Traceback (most recent call last):
 File "/usr/share/censor/censor/window.py", line 295, in on_save_response
 self.save_file(file)
 ~~~~~~~~~~~~~~^^^^^^
 File "/usr/share/censor/censor/window.py", line 302, in save_file
 self.document.save(file.get_path())
 ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
 File "/usr/share/censor/censor/document.py", line 156, in save
 mupdf_page.add_redact_annot(redaction_rotated, fill=False)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/usr/lib/python3.14/site-packages/pymupdf/__init__.py", line 10549, in add_redact_annot
 annot = self._add_redact_annot(quad, text=text, da_str=da_str,
 align=align, fill=fill)
 File "/usr/lib/python3.14/site-packages/pymupdf/__init__.py", line 9726, in _add_redact_annot
 annot = mupdf.pdf_create_annot(page, mupdf.PDF_ANNOT_REDACT)
 File "/usr/lib/python3.14/site-packages/mupdf/__init__.py", line 55925, in pdf_create_annot
 return _mupdf.pdf_create_annot(page, type)
 ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
mupdf.FzErrorArgument: code=4: not a dict (null)

Implementation

  1. Determine already when opening if a file cannot be saved (actually it is already saved once, but seems to be not enough, yet). Just run dummy mupdf_page.add_redact_annot and/or mupdf_page.clean_contents and stop opening the file
  2. Alternatively, fix the issue (or let upstream fix it)

Upstream issue

  • not reported, yet
## Description Sometimes it is impossible to save redactions, which leads to potential data loss (at least the already performed redactions are lost) ## Example files - samples_openpreserve/jhove-errors/PDF-HUL-35/143424271191706722106594310729442158189.pdf - samples_openpreserve/jhove-errors/PDF-HUL-35/A Defence of the New Tenseless Theory of Time.pdf - samples_openpreserve/pdf-handbuilt-test-corpus/T02-02_004_page-tree-non-existing-object-as-kid.pdf - samples_openpreserve/pdf-handbuilt-test-corpus/T02-03_006_page-object-missing.pdf ## Logs ```py Traceback (most recent call last): File "/usr/share/censor/censor/pymupdf_helpers.py", line 23, in clean_page mupdf_page.clean_contents(sanitize=False) ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^ File "/usr/lib/python3.14/site-packages/pymupdf/__init__.py", line 10870, in clean_contents mupdf.pdf_filter_page_contents( page.doc(), page, filter_) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.14/site-packages/mupdf/__init__.py", line 56523, in pdf_filter_page_contents return _mupdf.pdf_filter_page_contents(doc, page, options) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^ mupdf.FzErrorArgument: code=4: not a dict (null) ``` and ```py WARNING: Saving Document Failed: code=4: not a dict (null) Traceback (most recent call last): File "/usr/share/censor/censor/window.py", line 295, in on_save_response self.save_file(file) ~~~~~~~~~~~~~~^^^^^^ File "/usr/share/censor/censor/window.py", line 302, in save_file self.document.save(file.get_path()) ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^ File "/usr/share/censor/censor/document.py", line 156, in save mupdf_page.add_redact_annot(redaction_rotated, fill=False) ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.14/site-packages/pymupdf/__init__.py", line 10549, in add_redact_annot annot = self._add_redact_annot(quad, text=text, da_str=da_str, align=align, fill=fill) File "/usr/lib/python3.14/site-packages/pymupdf/__init__.py", line 9726, in _add_redact_annot annot = mupdf.pdf_create_annot(page, mupdf.PDF_ANNOT_REDACT) File "/usr/lib/python3.14/site-packages/mupdf/__init__.py", line 55925, in pdf_create_annot return _mupdf.pdf_create_annot(page, type) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^ mupdf.FzErrorArgument: code=4: not a dict (null) ``` ## Implementation 1. Determine already when opening if a file cannot be saved (actually it is already saved once, but seems to be not enough, yet). Just run dummy `mupdf_page.add_redact_annot` and/or `mupdf_page.clean_contents` and stop opening the file 2. Alternatively, fix the issue (or let upstream fix it) ## Upstream issue - not reported, yet
mahlzahn added this to the v0.7.2 milestone 2026年05月05日 16:14:36 +02:00
mahlzahn modified the milestone from v0.7.2 to v0.8.0 2026年06月23日 11:25:22 +02:00
Sign in to join this conversation.
No Branch/Tag specified
main
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
v0.1.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
censor/Censor#198
Reference in a new issue
censor/Censor
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?