sentry-python icon indicating copy to clipboard operation
sentry-python copied to clipboard

suggestion for fix for issue #2461

Open cameron-simpson opened this issue 2 years ago • 3 comments

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__.

Fixes GH-2461

cameron-simpson avatar Oct 26 '23 23:10 cameron-simpson

We have our contributing docs here, which contains some information about running our tests, but unfortunately the guide is not super detailed. If you can figure it out, I would suggest running the test suite with tox, which will allow you to run the tests with the same configuration as they are run in CI (in terms of Python version and installed dependencies). Otherwise, let me know and I will try to see if I can debug the test failures.

Also, now that the code formatting was fixed, I can see in our linting CI check that there is a typing issue. Please try to fix this as well. We use the mypy linter, which you should also be able to run locally.

szokeasaurusrex avatar Nov 06 '23 08:11 szokeasaurusrex

@cameron-simpson It actually seems that you can ignore the failing AWS Lambda tests for now; we recently opened an issue (#2487) because these tests have been failing for all contributor PRs; it is a problem with our tests, not your PR.

szokeasaurusrex avatar Nov 06 '23 10:11 szokeasaurusrex

Hey @cameron-simpson, we fixed the issue with our AWS Lambda tests. They currently are failing, but that is because for security reasons, I need to add a label to your PR to indicate that I have verified that your code won't leak our AWS Lambda secrets before the tests are allowed to run. Since I need to add this label every time you update the code, I will add this label once all other non-AWS Lambda checks are passing.

It looks like our CI checks and Python 3.8 common tests are failing. Please fix these, and then I will allow the AWS Lambda tests to run

szokeasaurusrex avatar Dec 13 '23 11:12 szokeasaurusrex

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 79.71%. Comparing base (d13fe23) to head (36cf20d). Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2466      +/-   ##
==========================================
- Coverage   79.77%   79.71%   -0.07%     
==========================================
  Files         133      133              
  Lines       14289    14290       +1     
  Branches     3003     3003              
==========================================
- Hits        11399    11391       -8     
- Misses       2067     2080      +13     
+ Partials      823      819       -4     
Files Coverage Δ
sentry_sdk/integrations/django/middleware.py 84.37% <100.00%> (+0.16%) :arrow_up:

... and 3 files with indirect coverage changes

codecov[bot] avatar Jul 15 '24 20:07 codecov[bot]

We can merge this as soon as master is green

sentrivana avatar Sep 03 '24 11:09 sentrivana