Skip to content
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

Merged
merged 3 commits into from
Sep 15, 2023
Merged

Handle missing request #1256

merged 3 commits into from
Sep 15, 2023

Conversation

Tenzer
Copy link
Contributor

@Tenzer Tenzer commented Sep 15, 2023

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have run the pre-commit run command to format and lint.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have added my name and/or github handle to AUTHORS.rst
  • I have added my change to CHANGES.rst
  • All new and existing tests passed.

Tenzer and others added 3 commits September 15, 2023 09:46
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.
Copy link
Member

@ddabble ddabble left a 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
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Merging #1256 (17a1d3a) into master (2e8e9a5) will decrease coverage by 0.16%.
The diff coverage is 50.00%.

@@            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              
Files Changed Coverage Δ
simple_history/middleware.py 73.91% <50.00%> (-6.09%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ddabble ddabble merged commit aa87e7c into jazzband:master Sep 15, 2023
19 checks passed
@Tenzer
Copy link
Contributor Author

Tenzer commented Sep 15, 2023

Thanks!

@Tenzer
Copy link
Contributor Author

Tenzer commented Oct 5, 2023

Any idea when a new release might be cut that includes this update?

@ddabble
Copy link
Member

ddabble commented Feb 26, 2024

@Tenzer This is now included in version 3.5.0 🙂

@Tenzer
Copy link
Contributor Author

Tenzer commented Feb 26, 2024

Great, thanks! I noticed earlier today and have upgraded to the latest version already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants