Open NicoEdge5 opened 2 months ago
@NicoEdge5, could you maybe send us links to the sentry errors for both:
Seeing both of the stacktraces will help us debug better.
If you don't want to send the error links publicly here on github, you can email them to me at neel.shah at sentry.io
.
@sl0thentr0py thanks for your feedback. I sent the requested data to you. I will update the issue here as soon as there is any progress for other people's sake (in case they have same or similar issue).
yes I received the email, thank you! I will set aside some time next week to debug your issue.
Hello! I have been facing the very same issue since August, before and after upgrading Django to the latest versions.
Did you get a chance to make progress on that issue ?
Are all Django customers affected or is this an issue on the customer side?
Kind regards
Hi @lbillon,
unfortunately no progress at the moment. I am still waiting also input from @sl0thentr0py As soon as I have an update I will share with everyone.
I set out to investigate and reproduce the issue, and after some digging, I suspect it's not directly related to sentry-sdk
itself.
Here’s what I found:
KeyError
messages also appeared in the logs independently of Sentry, so it seems not directly linked to sentry-sdk
.DEBUG = False
, which is typical of production environments where Sentry is active. With DEBUG = True
, when a 500 error occurs, Django displays the debug screen instead.DEBUG = False
, Django tries to display the corresponding error template, which could be customized for the application.KeyError
appears when Django fails to fully process or display the error page. This often happens if the error template triggers some data processing that may not be available when there's a server error.KeyError
issue for me.I hope this helps others who may be encountering the same problem and saves time for the Sentry team!
Cheers
okay I'm investigating this now, sorry for the delay.
I agree with @lbillon that this doesn't seem to be Sentry's problem. In the examples @NicoEdge5 provided, the key request
is missing in the context inside django-cms
here while rendering the django error template.
@lbillon are you also using django-cms
?
And can either or both of you provide your error templates so I can reproduce the problem?
ok I know what's happening in @NicoEdge5's case now
ALLOWED_HOSTS
doesn't have that particular host from your error so it bails early in the pipeline and django tried to render the error page.django.template.context_processors.request
doesn't run so the context doesn't have the request
keyclassytags
stuff which fails when accessing that context key
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.13.0
Steps to Reproduce
I am going nuts with this issue which I believe is coming from sentry-sdk for python, probably in combination with some other dependencies. I have a project in Django 4.2 with the sentry-sdk 2.13.0 which throws a KeyError request each time something is triggered on sentry, meaning if an error is reported I get X more errors reported about KeyError request (yes it is not just 1 for each report done). What confuses me is that the original error is shown correctly on sentry so I cannot say that sentry-sdk is failing reporting the issue. Moreover this happens also whenever I manually trigger a info/warning report from code to sentry.
To note, this started happening after upgrading the project dependencies, especially Django to 4.2. I am also not sure it is a bug directly on sentry_sdk probably is the combination with something else.
I also thought it could have been a context_processor issue but context_processor for request is in the settings (see code below)
Any help or suggestion is much appreciated.
Stack trace:
Context processors:
pip freeze --all:
Expected Result
Report the issue on sentry.
Actual Result
Reports the error followed by many KeyError 'request' triggered by the first error.