Root app middleware receives wrong app context#2550
Conversation
|
Is it related to #2454 ? |
|
not sure |
|
|
9a2f7bb to
b072845
Compare
|
So, the fix is as following:
Whew... profit! Guys, your thoughts? |
Codecov Report
@@ Coverage Diff @@
## master #2550 +/- ##
==========================================
+ Coverage 97.55% 97.57% +0.01%
==========================================
Files 40 40
Lines 8057 8078 +21
Branches 1409 1411 +2
==========================================
+ Hits 7860 7882 +22
+ Misses 75 74 -1
Partials 122 122
Continue to review full report at Codecov.
|
|
Adding a new middleware is not ideal maybe but I can live with it -- an extra middleware is better than broken functionality. |
* add failing test showing invalid request.app in middleware * implement UrlMappingMatchInfo.current_app attribute with context manger setter * fix bad inlined-inlined-loop) * Add changes
* add failing test showing invalid request.app in middleware * implement UrlMappingMatchInfo.current_app attribute with context manger setter * fix bad inlined-inlined-loop) * Add changes
|
This change has broken existing functionality e.g. earlier within a view in a sub-application, I could always do request.app and get the sub-application instance. Now it always returns the main application instance which basically defeats the purpose of sub-application. E.g. if I have a routes defined in the sub-application, earlier they used to work fine via request.app.router['<route_name>']. Now since request.app always returns the main app, it is not aware of the subapplication route names and errors out: |
|
Hi, @SoumenDass , |
|
All my middlewares are in the main app |
|
ok, thanks, I will check your issue |
|
Thanks - for now, I've rolled back my deployment to 2.3.3 where this issue does not happen. |
|
I've just updated the test and made a fix. |
* yield _fix_request_current_app middleware uncoditionally; update test; (see #2550) * Add change notes
* yield _fix_request_current_app middleware uncoditionally; update test; (see #2550) * Add change notes
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
Long story short
When handling request to sub-application root application's middlewares see wrong
request.appinstance — sub-app instead of the one they attached to.This PR demonstrates it (adds failing test) but has no fix yet.