fix(bundle-analysis): clean up temp files on load failure#917
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4b2c3c5 to
4adb001
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4adb001. Configure here.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #917 +/- ##
=======================================
Coverage 91.89% 91.89%
=======================================
Files 1316 1316
Lines 50633 50639 +6
Branches 1625 1625
=======================================
+ Hits 46531 46537 +6
Misses 3796 3796
Partials 306 306
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Make sure |
|
Confirmed locally that unlinking fd does not affect db_path. |

Summary
BundleAnalysisReportLoader.load()calledtempfile.mkstemp()but never deleted the temp file on theFileNotInStorageErrorpath (returnedNonewithout cleanup) or on any unexpected exception pathNo space left on device(WORKER-WNZ)try/exceptso both error paths callos.unlink(db_path)before returning/re-raising; the happy path still transfers ownership to the returnedBundleAnalysisReport, which has its owncleanup()methodTest plan
test_load_cleans_up_tempfile_on_file_not_found— patchesmkstempto capture the path, asserts file no longer exists afterload()returnsNonetest_load_cleans_up_tempfile_on_unexpected_error— same, but for an unexpectedRuntimeErrorthat should re-raisetest_save_load_bundle_report— existing happy-path test still passes🤖 Generated with Claude Code
Note
Low Risk
Low risk: narrow change to temporary-file lifecycle in
BundleAnalysisReportLoader.load, plus targeted unit tests; only impacts failure paths and should reduce disk-leak incidents.Overview
Fixes
BundleAnalysisReportLoader.load()to always clean up themkstemp-created SQLite temp file when the report is missing (FileNotInStorageError) or when any unexpected exception occurs, instead of leaking files on disk.Adds unit tests that assert the temp file is deleted on both not found and unexpected error paths, while keeping the existing save/load happy-path behavior intact.
Reviewed by Cursor Bugbot for commit f2003b3. Bugbot is set up for automated code reviews on this repo. Configure here.