-
Notifications
You must be signed in to change notification settings - Fork 514
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
SentryWrappingMiddleware.__init__ fails if super() is object #2461
Comments
Well, things are more complex than I'd thought.
which still evokesthe This may be harder for you to reproduce than I'd thought. |
Hey @cameron-simpson, thanks for reporting this. Django 2.2 tests are part of our pipeline so it's unlikely this is a general problem with the integration not working at all, it's indeed more likely that there is some custom middleware stuff going on. I'll put this in our backlog. Could you let us know what your |
Listed below. And now you point me there, I wrote
|
Hmm, removing |
I'm poking around in The MRO of this In the However the docs for I'm suspecting that this is breaking the lookup for And so it calls I don't see why this doesn't explode on the other middleware classes we've got in play at my end, but maybe the root cause is how Or maybe the behaviour of |
Belay that: I'm being deceived by this code at the bottom of the
such that my debug statements are printing the name of the wrapped class. An |
Oh, here we go. Possible diagnosis. We define
and we define
such that the MRO of I warrant that Maybe |
Suggested fix: It appears the async support for middleware came in with Django 3.1 (hence the 3.1 test quoted in the previous comment). What if the start of
also required Django 3.1 for |
Hey @cameron-simpson thanks for all the additional information! As this is for quite old Django versions, it is not on top of our priority list. But if anyone else is having this issue please upvote this issue so we know that there is demand! |
@cameron-simpson We also welcome community contributions, so if you would like to try to fix the problem yourself, please feel free to open a PR |
On 31Oct2023 04:00, Daniel Szoke ***@***.***> wrote:
***@***.*** We also welcome community contributions, so if
you
would like to try to fix the problem yourself, please feel free to open
a PR
I did submit a PR! - Cameron
|
@szokeasaurusrex , the PR link is here: #2466 |
Thank you, I see it now -- I had missed the PR when scrolling through the issue earlier. Will take a look as soon as I have time |
…ject As described in issue #2461, the SentryWrappingMiddleware MRO is just object if Django < 3.1 (when async middleware became a thing), but the async_capable check inside the class only looks for the async_capable attribute inside the middleware class. This PR makes that check also conditional on Django >= 3.1. Otherwise the code calls super(.....).__init__(get_response) and for Django < 3.1 this only finds object.__init__, not the wrapped middleware __init__. --- Co-authored-by: Daniel Szoke <daniel.szoke@sentry.io>
…ject As described in issue getsentry#2461, the SentryWrappingMiddleware MRO is just object if Django < 3.1 (when async middleware became a thing), but the async_capable check inside the class only looks for the async_capable attribute inside the middleware class. This PR makes that check also conditional on Django >= 3.1. Otherwise the code calls super(.....).__init__(get_response) and for Django < 3.1 this only finds object.__init__, not the wrapped middleware __init__. --- Co-authored-by: Daniel Szoke <daniel.szoke@sentry.io>
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.32.0
Steps to Reproduce
Oh, this is in Django version 2.2.6, which I accept is pretty old. We've a local ticket to upgrade that but I've no idea when it will get attention.
1: Install sentry in a django app with probably no other middleware.
2:
manage.py runserver
This raises a
TypeError
atsentry-python/sentry_sdk/integrations/django/middleware.py
Line 140 in 085595b
because it is passing
get_response
, and the super type__init__
method comes fromobject
, which does not accept an additional parameter.I've worked around this locally by hand commenting out the parameter.
Maybe there's some check which can be made of what
super(SentryWrappingMiddleware, self).__init__
resolves to?Expected Result
The dev server starts up as normal.
Actual Result
The text was updated successfully, but these errors were encountered: