diff --git a/kukkuu/settings.py b/kukkuu/settings.py index a1c640fc..db66a4a9 100644 --- a/kukkuu/settings.py +++ b/kukkuu/settings.py @@ -3,10 +3,10 @@ from datetime import datetime import environ -from jose import ExpiredSignatureError import sentry_sdk from django.core.exceptions import ImproperlyConfigured from django.utils.translation import gettext_lazy as _ +from jose import ExpiredSignatureError from sentry_sdk.integrations.django import DjangoIntegration from kukkuu.consts import CSP @@ -149,16 +149,23 @@ def sentry_before_send(event, hint): """ Ignore certain errors from being sent to Sentry. + Some Graphene errors are generic Exceptions that are not useful to log. + Since they are generic, we need to ignore them by their message. NOTE: The `ignore_errors` option is actually deprecated, nevertheless it's included in the init configuration. See https://github.com/getsentry/sentry-python/issues/149 """ IGNORED_ERRORS_CLASSES = (ExpiredSignatureError, AuthenticationExpiredError) + IGNORED_ERROR_MESSAGES = [ + "Unable to parse global ID", + ] if "exc_info" in hint: exc_type, exc_value, tb = hint["exc_info"] if isinstance(exc_value, IGNORED_ERRORS_CLASSES): return None + if any(msg in exc_value.args[0] for msg in IGNORED_ERROR_MESSAGES): + return None return event diff --git a/kukkuu/tests/test_sentry.py b/kukkuu/tests/test_sentry.py index 7cc400f6..daf1eaba 100644 --- a/kukkuu/tests/test_sentry.py +++ b/kukkuu/tests/test_sentry.py @@ -5,6 +5,8 @@ from kukkuu.settings import sentry_before_send test_cases = [ + (Exception("Unable to parse global ID."), True), + (Exception('Unable to parse global ID "some_id".'), True), (ExpiredSignatureError("Expired signature"), True), (AuthenticationExpiredError("Authentication expired"), True), (Exception("Some other error"), False),