Skip to content
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

Merged
merged 2 commits into from
Jun 8, 2022

Conversation

nikhars
Copy link
Member

@nikhars nikhars commented Jun 8, 2022

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.

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.
@nikhars nikhars requested a review from a team as a code owner June 8, 2022 16:30
@nikhars nikhars requested a review from volokluev June 8, 2022 16:31
@codecov-commenter
Copy link

codecov-commenter commented Jun 8, 2022

Codecov Report

Merging #2797 (83fc010) into master (6e64018) will increase coverage by 0.00%.
The diff coverage is 94.44%.

❗ Current head 83fc010 differs from pull request most recent head c24e798. Consider uploading reports for the commit c24e798 to get more accurate results

@@           Coverage Diff           @@
##           master    #2797   +/-   ##
=======================================
  Coverage   92.82%   92.82%           
=======================================
  Files         609      609           
  Lines       28593    28600    +7     
=======================================
+ Hits        26541    26548    +7     
  Misses       2052     2052           
Impacted Files Coverage Δ
snuba/utils/serializable_exception.py 97.91% <ø> (ø)
snuba/state/rate_limit.py 91.47% <88.88%> (-0.20%) ⬇️
snuba/datasets/metrics_bucket_processor.py 95.40% <100.00%> (+0.95%) ⬆️
tests/utils/test_serializable_exception.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e64018...c24e798. Read the comment docs.

Copy link
Member

@volokluev volokluev left a 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

Comment on lines 284 to 285
scope = exc.extra_data.get("scope", "")
name = exc.extra_data.get("name", "")
Copy link
Member

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):
"""
Copy link
Member

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

@nikhars nikhars merged commit 557098a into master Jun 8, 2022
@nikhars nikhars deleted the fix/rate-limit-metrics branch June 8, 2022 21:05
JoshFerge pushed a commit that referenced this pull request Jun 13, 2022
)

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants