-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rate-limit): Don't override SerializableException constructor #2797
Conversation
Overriding SerializableException constructor is a bad idea since making the original exception back from a serialized version does not work correctly. Use extra_data instead.
Codecov Report
@@ Coverage Diff @@
## master #2797 +/- ##
=======================================
Coverage 92.82% 92.82%
=======================================
Files 609 609
Lines 28593 28600 +7
=======================================
+ Hits 26541 26548 +7
Misses 2052 2052
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, some comments that are purely educational
snuba/state/rate_limit.py
Outdated
scope = exc.extra_data.get("scope", "") | ||
name = exc.extra_data.get("name", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: if you wanted to have the exc.scope
property you could still do it. That method would just get it from extra_data
@@ -86,6 +86,14 @@ def _get_registry() -> _ExceptionRegistry: | |||
|
|||
|
|||
class SerializableException(Exception): | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could enforce this in the __init_subclass__
function if you wanted
Overriding SerializableException constructor is a bad idea since making
the original exception back from a serialized version does not work
correctly. Use extra_data instead.