Skip to content

add_warning: store exceptions given as args as text, not the exception (1.4-maint) - #10571

Open
ThomasWaldmann wants to merge 1 commit into
borgbackup:1.4-maintfrom
ThomasWaldmann:add-warning-text-14
Open

ThomasWaldmann wants to merge 1 commit into
borgbackup:1.4-maintfrom
ThomasWaldmann:add-warning-text-14

Conversation

@ThomasWaldmann

Copy link
Copy Markdown
Member

Backport of #10331 to 1.4-maint.

What

For a BackupWarning, the args of the warning include the caught BackupError exception. Storing that in the global warnings list (add_warning()) kept the exception - and thus its traceback and the frames (with all their locals) of the code that failed - alive for the rest of the borg run, one per warning. For a failed file in borg extract, that is the extract_item() frame including the chunk data that was being written; on a full disk, every remaining file adds another chunk.

How

add_warning() stores exceptions given as args as their message text (str(exc)), which is what formatting the warning message with the exception gives anyway. The helpers/__init__.py change cherry-picked cleanly.

Tests

The tests from #10331 are moved to the 1.4-maint test modules:

  • testsuite/archiver.py: regression test at the print_warning_instance() level (the exception wrapped by the BackupWarning must be freed afterwards, checked via weakref after a gc.collect() for PyPy). Fails without the fix, passes with it.
  • testsuite/helpers.py: unit test for the get_ec() warnings logic.

🤖 Generated with Claude Code

For a BackupWarning, the args of the warning include the caught BackupError
exception. Storing that in the global warnings list kept the exception - and
thus its traceback and the frames (with all their locals) of the code that
failed - alive for the rest of the borg run, one per warning: for a failed
file in borg extract, that is the extract_item frame including the chunk
data that was being written. On a full disk, every remaining file adds
another chunk.

Store the exception's message text instead, which is what formatting the
warning message with the exception gives anyway.

Add a regression test (the exception wrapped by a BackupWarning must be
freed after print_warning_instance()) and a unit test for the get_ec()
warnings logic.

Backport of borgbackup#10331 (cherry picked from commit 366db25,
tests moved to the 1.4-maint test modules).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.16%. Comparing base (e81a51f) to head (d686ed1).
⚠️ Report is 12 commits behind head on 1.4-maint.

Additional details and impacted files
@@              Coverage Diff              @@
##           1.4-maint   #10571      +/-   ##
=============================================
+ Coverage      82.11%   82.16%   +0.04%     
=============================================
  Files             38       38              
  Lines          11485    11486       +1     
  Branches        1810     1810              
=============================================
+ Hits            9431     9437       +6     
+ Misses          1468     1465       -3     
+ Partials         586      584       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
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