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

bug 1619644: handle None values in throttler #490

Merged
merged 1 commit into from Mar 24, 2020
Merged

bug 1619644: handle None values in throttler #490

merged 1 commit into from Mar 24, 2020

Conversation

willkg
Copy link
Collaborator

@willkg willkg commented Mar 24, 2020

It's now possible for the collector to get None values for crash annotations. None is not a string which makes some of the throttler rules sad.

This adds a safe_get function which gets the value from the crash and forces it to be a string. Then we can use string functions on it.

:return: string value

"""
return str(data.get(key, default))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a single function that does this is easier than adjusting the code everywhere. This is a sanitizing function, so as we hit issues with new and exciting data problems, we can tweak this function accordingly.

@@ -28,6 +28,20 @@
RESULT_TO_TEXT = {0: "ACCEPT", 1: "DEFER", 2: "REJECT", 3: "FAKEACCEPT"}


def safe_get(data, key, default=""):
"""Return data[key] or empty string.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops--this is wrong now. I need to update this.

It's now possible for the collector to get None values for crash
annotations. None is not a string which makes some of the throttler
rules sad.

This adds a "safe_get" function which gets the value from the crash and
forces it to be a string. Then we can use string functions on it.
@willkg
Copy link
Collaborator Author

willkg commented Mar 24, 2020

self-r+

@willkg willkg merged commit 8b2a61d into mozilla-services:master Mar 24, 2020
@willkg willkg deleted the 1619644-nonetype branch March 24, 2020 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant