Skip to content

Do not silently discard errors raised while finishing a ZIM - #354

Merged
benoit74 merged 1 commit into
mainfrom
fix-silent-finish-error
Oct 16, 2026
Merged

benoit74 merged 1 commit into
mainfrom
fix-silent-finish-error

Conversation

@benoit74

@benoit74 benoit74 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Creator.finish() wrapped the call into libzim's finishZimCreation() with a blanket except RuntimeError: pass. That was originally meant to make a redundant/double call to finish() a no-op (see test_double_finish), but it also silently discards a genuine finalization failure: the scraper then exits successfully (code 0) with no final .zim file and no error logged anywhere.

This is the root cause of openzim/warc2zim#462: warc2zim logs "Detect dangling redirects" / "Detect loops and/or blind chains of redirects" / "Index titles" (all from libzim's finishZimCreation()), then an error occurs somewhere later in that same native finalization sequence, gets turned into a Python RuntimeError, and is swallowed here. Converter.run() then returns normally, warc2zim exits 0, and the half-written .zim.tmp is removed by libzim's own cleanup with no further log line.

Changes

  • Track whether finish() already ran via a _finish_called flag instead of blindly catching RuntimeError. A second call is still a no-op (preserving the original intent), but a real error on the first call now propagates instead of being discarded.
  • Added test_finish_error_propagates covering this.

@benoit74 benoit74 self-assigned this Oct 16, 2026
Creator.finish() caught and dropped every RuntimeError raised by
libzim's finishZimCreation(), including genuine finalization failures,
so a scraper could exit successfully (code 0) with no final ZIM file
and no error logged. Track whether finish() already ran instead, so a
second call stays a no-op but a real error on the first call now
propagates.
@benoit74
benoit74 force-pushed the fix-silent-finish-error branch from a3e8c7f to e7d9b60 Compare October 16, 2026 11:56
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (1285116) to head (e7d9b60).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #354   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           42        42           
  Lines         2728      2729    +1     
  Branches       405       406    +1     
=========================================
+ Hits          2728      2729    +1     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benoit74 benoit74 added this to the 5.5.0 milestone Oct 16, 2026
@benoit74
benoit74 merged commit 936498a into main Oct 16, 2026
10 checks passed
@benoit74
benoit74 deleted the fix-silent-finish-error branch October 16, 2026 12:00
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.

1 participant