Repository navigation
fix(log): preserve the active handler when destination setup fails - #319
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
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 configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesLogging File Relocation
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to Logging stays usable and warnings reach the original log file when destination setup fails, so a relocation can be retried. Regression tests cover failure and success cases. No merge-blocking risk is evident. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Signed-off-by: shinichi nagata <128954611+shin4141@users.noreply.github.com>
69d4ce3 to
0a74b2d
Compare
|
@shin4141, Thanks for the contribution. I removed the test changes because they validate implementation details rather than the API contract. Given the current FOSSLight Scanner usage, these additional tests do not provide sufficient value. |
What this fixes
If destination directory creation fails in
move_log_file, the original file handler has already been closed and removed. A caller that catches the exception can emit a warning, but that warning is missing from the original log.Create the destination directory before closing or removing the original handler, so a warning logged after directory creation fails is still written to the original log. Logging also remains usable for a later relocation retry.
Why it matters
Keeping failure diagnostics in the original log avoids an extra reproduction just to recover why relocation failed.
The current FOSSLight Scanner path creates the destination directory before calling
move_log_file, so the impact there is limited. This fix primarily protects callers that use the Util API directly.Review scope
os.makedirs(...)runs before detaching the original file handler.src/fosslight_util/set_log.pyandtests/test_set_log.py.Evidence
Verified in Cloud on Linux / Python 3.12.14 against upstream main
c20cc2db02bc76849dd009fd4b0cb639169fdedb:The four related-suite warnings come from existing CycloneDX fixtures whose root component has no declared dependencies.
Only Linux / Python 3.12 was verified. External download integration tests (
tests/test_download.pyand the two live Packagist cases), legacy tests, other Python versions, and other platforms were not verified. The completetox -e releaseCI workflow has not been run locally.