feat: retry broke after #1623 started deleting staged temp files#1709
Conversation
immediately after processing. The enhanced task API still marks those failures as RETRYABLE, but retry then fails with source_file_missing because the temp path no longer exists on disk. Clean up upload temps per file only when they are not retryable: - keep temps for failed local uploads classified as RETRYABLE - delete temps for successes and non-retryable failures - on cancel, force-delete all temps (no retry expected) - if unlink fails, keep the path in temp_file_paths so cleanup can be retried later (safe_unlink swallows errors, so verify with exists)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughTaskService centralizes staged upload-temp cleanup with ChangesTemp File Cleanup Refactoring
Sequence Diagram(s)sequenceDiagram
participant TaskService
participant UploadTask
participant FileSystem
TaskService->>UploadTask: iterate upload_task.temp_file_paths
TaskService->>TaskService: _file_task_for_temp_path(upload_task, temp_path)
TaskService->>TaskService: _is_retryable_local_upload_temp(upload_task, temp_path)
alt retryable and not forced
TaskService-->>UploadTask: retain temp_path
else non-retryable or forced
TaskService->>FileSystem: safe_unlink(temp_path)
FileSystem-->>TaskService: unlink result / os.path.exists check
TaskService->>UploadTask: update temp_file_paths based on unlink outcome
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/services/task_service.py`:
- Around line 1374-1400: When evicting aged TaskStatus.COMPLETED/FAILED tasks in
TaskService.cleanup_old_tasks (and during shutdown), ensure you call the
existing _cleanup_upload_temp_files(upload_task, force=True) for each upload
task being removed so retained temp files in upload_task.temp_file_paths are
reclaimed; locate where tasks are removed from task_store (and shutdown logic)
and invoke _cleanup_upload_temp_files before deleting/evicting the task, passing
force=True to guarantee deletion of RETRYABLE temp files and updating task_store
accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f8eeeead-d723-44be-8914-aa2717c66666
📒 Files selected for processing (2)
src/services/task_service.pytests/unit/test_task_service_retry_failed_files.py
f091a1e to
5271a73
Compare
lucaseduoli
left a comment
There was a problem hiding this comment.
Working perfectly. I think Mike's feedbacks are good
c638312 to
26095a3
Compare
upload retry broke after #1623 started deleting staged temp files
immediately after processing. The enhanced task API still marks those
failures as RETRYABLE, but retry then fails with source_file_missing
because the temp path no longer exists on disk.
Clean up upload temps per file only when they are not retryable:
retried later (safe_unlink swallows errors, so verify with exists)
Add unit tests for retryable retention, mixed success/failure cleanup,
failed unlink tracking, and ensuring retryable temps are never unlinked.
Summary by CodeRabbit
Bug Fixes
Tests