Keep temp cleanup failures from stranding the reports - #195
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe scanner adds retryable removal for read-only files. Temporary extraction and finalization cleanup use this helper. Finalization tracks failed removal and move operations. ChangesCleanup resilience
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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: 2
🧹 Nitpick comments (1)
src/fosslight_scanner/fosslight_scanner.py (1)
72-85: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winLimit cleanup handlers to filesystem errors.
except Exceptionalso hides invalid arguments and programming errors. CatchOSErrorfor filesystem operations and let unexpected exceptions surface.🤖 Prompt for 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. In `@src/fosslight_scanner/fosslight_scanner.py` around lines 72 - 85, Update the cleanup logic around the os.walk, os.chmod, and shutil.rmtree operations to catch only OSError rather than broad Exception, while preserving the existing warning and successful return behavior. Allow invalid arguments and other unexpected programming errors to propagate, and apply the same filesystem-error restriction to the earlier retry handler in this cleanup flow.Source: Linters/SAST tools
🤖 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/fosslight_scanner/fosslight_scanner.py`:
- Around line 594-604: Track each failed move in the move loop around
shutil.move, preserving failed items under output_path instead of deleting them
during remove_tree(output_path). Only rewrite final_reports paths when the
corresponding report was successfully moved and exists under final_dir; leave
failed-report paths pointing to their retained staging locations.
- Around line 67-82: Update remove_tree to preserve existing permission bits by
OR-ing stat.S_IWRITE with each entry’s mode from os.stat, and apply the same
update to the root path before walking so read-only roots remain traversable.
Add a regression test covering removal of nested read-only directories.
---
Nitpick comments:
In `@src/fosslight_scanner/fosslight_scanner.py`:
- Around line 72-85: Update the cleanup logic around the os.walk, os.chmod, and
shutil.rmtree operations to catch only OSError rather than broad Exception,
while preserving the existing warning and successful return behavior. Allow
invalid arguments and other unexpected programming errors to propagate, and
apply the same filesystem-error restriction to the earlier retry handler in this
cleanup flow.
🪄 Autofix
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 Plus
Run ID: 380225ab-785d-4576-97e2-bf2c4d8c7574
📒 Files selected for processing (1)
src/fosslight_scanner/fosslight_scanner.py
Summary by CodeRabbit