-
-
Notifications
You must be signed in to change notification settings - Fork 483
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
Handle missing request #1256
Handle missing request #1256
Conversation
The change in #1188 removed a check for if the request context had a "request" entry in it before trying to delete the request data. This has a side effect of breaking tests in order projects in very specific circumstances, where multiple requests pass through the middleware, concurrently, inside the same thread, as it means the middleware then may try to remove the request key on a context where it already has been removed. This shouldn't have any impact in real life scenarios.
Also added a missing reference to the previously merged PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you! 😊
Codecov Report
@@ Coverage Diff @@
## master #1256 +/- ##
==========================================
- Coverage 97.09% 96.94% -0.16%
==========================================
Files 23 23
Lines 1272 1275 +3
Branches 209 209
==========================================
+ Hits 1235 1236 +1
- Misses 19 21 +2
Partials 18 18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thanks! |
Any idea when a new release might be cut that includes this update? |
@Tenzer This is now included in version 3.5.0 🙂 |
Great, thanks! I noticed earlier today and have upgraded to the latest version already. |
Description
The change in #1188 removed a check for if the request context had a "request" entry in it before trying to delete the request data.
Motivation and Context
This has a side effect of breaking tests in order projects in very specific circumstances, where multiple requests pass through the middleware, concurrently, inside the same thread, as it means the middleware then may try to remove the request key on a context where it already has been removed.
In our case we make us of before_after to test some behaviours that are specific to concurrent requests, which allows us to execute concurrent requests inside one test. In those cases the test have started failing with django-simple-history 3.4.0 because an
AttributeError
is raised when the second request passes back up through the middleware, and tries to delete the request data after it already has been done as part of the first request.This shouldn't have any impact in real-life scenarios.
How Has This Been Tested?
I have run our test suite (for proprietary code) before and after this change to verify it no longer raises the
AttributeError
and our test suite passes.Types of changes
Checklist:
pre-commit run
command to format and lint.AUTHORS.rst
CHANGES.rst