Log error when AttrR fails to validate value in update#330
Conversation
📝 WalkthroughWalkthroughThe update method in the attribute reader class now wraps the datatype validation call with error handling, logging validation errors with context before re-raising the exception. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #330 +/- ##
==========================================
+ Coverage 90.85% 90.86% +0.01%
==========================================
Files 70 70
Lines 2547 2551 +4
==========================================
+ Hits 2314 2318 +4
Misses 233 233 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/fastcs/attributes/attr_r.py (1)
81-83: Include exception context in the validation-failure log.Line 82 logs a plain error message but drops the caught exception details/traceback. Use exception-aware logging here (same pattern used at lines 100-104) so failures are diagnosable.
♻️ Proposed fix
- except ValueError: - logger.error("Failed to validate value", value=repr(value), attribute=self) + except ValueError as e: + logger.opt(exception=e).error( + "Failed to validate value", value=repr(value), attribute=self + ) raise🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/fastcs/attributes/attr_r.py` around lines 81 - 83, The except ValueError handler currently logs without exception context; update the handler in attr_r.py to include the caught exception (use logger.exception(...) or logger.error(..., exc_info=True)) so the traceback is recorded, preserving the existing structured fields (value=repr(value), attribute=self) and then re-raise; look for the ValueError except block associated with the validation logic (the logger variable and self/attribute usage) and make it mirror the exception-aware logging used at lines 100-104.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/fastcs/attributes/attr_r.py`:
- Around line 81-83: The except ValueError handler currently logs without
exception context; update the handler in attr_r.py to include the caught
exception (use logger.exception(...) or logger.error(..., exc_info=True)) so the
traceback is recorded, preserving the existing structured fields
(value=repr(value), attribute=self) and then re-raise; look for the ValueError
except block associated with the validation logic (the logger variable and
self/attribute usage) and make it mirror the exception-aware logging used at
lines 100-104.
Summary by CodeRabbit