fix(file): clean up failed cloud downloads - #14904
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe cloud download handlers now close temporary files before raising download errors and removing failed downloads. S3 and Google Drive tests track temporary files directly and verify that cleanup succeeds. ChangesCloud download cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change closes temporary-file handles before cleanup for failed S3 and Google Drive downloads, reducing cleanup failures without altering public interfaces or deployment behavior. No actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 8 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (8 passed)
Full details: Linked Issues checkExplanation The implementation addresses issue Full details: Test Coverage For New ImplementationsExplanation The PR includes targeted regression tests for both changed failure paths: Full details: Test Quality And CoverageExplanation Tests adequately cover the changed cleanup behavior. The S3 and Google Drive failure tests invoke the real component methods, force a download exception, require the expected RuntimeError, and assert that the tracked temporary file is removed. Their guarded Path.unlink mock fails while the temporary handle is open, so the tests verify the required close-before-unlink ordering. Existing success-path tests also verify local cleanup for both providers. The changes use pytest patterns, and no async or API endpoint testing applies. Full details: Test File Naming And StructureExplanation The pull request passes the test naming and structure check. The changed backend module is Full details: Excessive Mock Usage WarningExplanation PASS. The changed tests do not excessively mock core logic. Each test calls the real ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Move the cloud-download temp-file cleanup for S3 and Google Drive out of the
NamedTemporaryFilecontext so the file handle is closed before unlinking on failure.Tests
env -u ALL_PROXY -u HTTP_PROXY -u HTTPS_PROXY -u all_proxy -u http_proxy -u https_proxy uv run pytest src/backend/tests/unit/components/files_and_knowledge/test_file_component.py -qenv -u ALL_PROXY -u HTTP_PROXY -u HTTPS_PROXY -u all_proxy -u http_proxy -u https_proxy uv run ruff check src/lfx/src/lfx/components/files_and_knowledge/file.py src/backend/tests/unit/components/files_and_knowledge/test_file_component.pyenv -u ALL_PROXY -u HTTP_PROXY -u HTTPS_PROXY -u all_proxy -u http_proxy -u https_proxy uv run ruff format src/lfx/src/lfx/components/files_and_knowledge/file.py src/backend/tests/unit/components/files_and_knowledge/test_file_component.py --checkFixes #14866
Summary by CodeRabbit