Sentry is not filtering out NotAuthenticatedError from Django
See original GitHub issueHow do you use Sentry?
Sentry Saas (sentry.io)
Version
1.5.8
Steps to Reproduce
I am using Django(2.0.13) with graphql. Steps:
- Init sentry with before_send method and filter out NotAuthenticated Exception i.e. return None for this error.
- Raise an NotAuthenticated exception in your code for a request.
- Notice that error is still reported to sentry.io and not filtered out.
Code sample:
from django.core.exceptions import PermissionDenied
from rest_framework.exceptions import NotAuthenticated, AuthenticationFailed
def before_send(event, hint):
"""Filter out following exceptions from sentry, since these are quite common"""
if 'exc_info' in hint:
exc_type, exc_value, tb = hint['exc_info']
if isinstance(exc_value, (
NotAuthenticated,
AuthenticationFailed,
PermissionError,
PermissionDenied,
)):
return None
return event
sentry_sdk.init(
dsn=env("DJANGO_SENTRY_DSN"),
integrations=[DjangoIntegration(), CeleryIntegration()],
send_default_pii=True,
debug=env.bool('DJANGO_SENTRY_DEBUG', default=False),
before_send=before_send,
)
Expected Result
NotAuthenticated exception should not be sent to sentry.io.
Actual Result
NotAuthenticated sent to sentry.io.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Filtering for Django - Sentry Documentation
The Sentry SDKs have several configuration options to help you filter out events. We also offer Inbound Filters to filter events in sentry.io....
Read more >How can I filter out errors on sentry to avoid consuming my ...
According to the sentry documentation on quota usage, events filtered via inbound filters are not affecting your quota.
Read more >Filtering and Sampling Events for Django
When a string or a non-error object is raised, Sentry creates a synthetic exception so you can get a basic stack trace. This...
Read more >Allow filtering/custom handling of with_locals values #217
I am trying to figure out if the Django integration should change the ... a local variable in the stack of an error...
Read more >Sentry is great for tracking Django errors - Matt's Dev Blog
You've deployed a Django app to a webserver and now it's not working. Your app is throwing 500 Internal Server Errors - what's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you so much. I really appreciate it.
It answers my question - if you like, you can close this issue or perhaps leave it open for enhancement. It’s all up to you.