SG-41264 Fixup exception instance don't all have a message attribute#306
SG-41264 Fixup exception instance don't all have a message attribute#306julien-lang wants to merge 3 commits intomasterfrom
Conversation
AttributeError: 'Exception' object has no attribute 'message'
There was a problem hiding this comment.
Pull request overview
This PR fixes an AttributeError that occurs when exception instances don't have a message attribute. The fix adds proper fallback handling when reporting errors, checking for the message attribute first, then falling back to args[0], and finally using a generic error message.
Key changes:
- Added conditional checks to handle exceptions without a
messageattribute - Implemented fallback chain:
message→args[0]→ "unknown error"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Regression FixQA was correct - the original PR only fixed 1 out of 5 occurrences of e.message in the codebase. Found and fixed 4 additional occurrences:
All now use the same fallback pattern: hasattr(e, "message") → e.args[0] → "unknown error" |
|
Regression fix: Found and fixed 4 additional e.message occurrences in server_protocol.py:179, api_v1.py:91, api_v1.py:145, and process_manager.py:226. All now use proper fallback handling. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #306 +/- ##
===========================================
+ Coverage 41.02% 65.06% +24.03%
===========================================
Files 284 24 -260
Lines 43483 1892 -41591
===========================================
- Hits 17840 1231 -16609
+ Misses 25643 661 -24982
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a8152d3 to
82c2c56
Compare
AttributeError: 'Exception' object has no attribute 'message'