The Fix
The current AppContext object is passed through the various request dispatch methods, rather than each method accessing the proxies. This change improves performance and compatibility during a deprecation period.
Based on closed pallets/flask issue #5815 · PR/commit linked
Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.
@@ -9,6 +9,11 @@ Unreleased
when dispatching a request. This greatly simplifies the internal code for tracking
the active context. :issue:`5639`
+- Many ``Flask`` methods involved in request dispatch now take the current
+ ``AppContext`` as the first parameter, instead of using the proxy objects.
+ If subclasses were overriding these methods, the old signature is detected,
Option A — Apply the official fix\nThe current AppContext object is passed through the various request dispatch methods, rather than each method accessing the proxies. This change improves performance and compatibility during a deprecation period.\nWhen NOT to use: This fix is not suitable for applications heavily relying on the old method signatures.\n\n
Why This Fix Works in Production
- Trigger: I think nobody wants to update their application to a change like this, also because it would imply having to propagate the vars deeper into application code,…
- Mechanism: Flask methods were accessing context proxies instead of passing AppContext directly
- If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.
Why This Breaks in Prod
- Flask methods were accessing context proxies instead of passing AppContext directly
- Production symptom (often without a traceback): I think nobody wants to update their application to a change like this, also because it would imply having to propagate the vars deeper into application code, util functions, etc. that currently use the profies.
Proof / Evidence
- GitHub issue: #5815
- Fix PR: https://github.com/pallets/flask/pull/5818
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.67
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“ah, internals only. not such a big deal then, as it would just affect people subclassing...”
“Not a fan of deprecating it, for 99% of all apps the performance difference is unnecessary so the convenience wins IMHO”
“I've managed to write some code that can detect overridden methods with the old signature, and wrap them and the corresponding base method so they'll…”
“This would _only_ be for methods on Flask (Scaffold, etc), it would not require passing them throughout your own code”
Failure Signature (Search String)
- I think nobody wants to update their application to a change like this, also because it would imply having to propagate the vars deeper into application code, util functions, etc.
- It may be very difficult to do this in a way that existing overridden code will not fail and will show a deprecation warning.
Copy-friendly signature
Failure Signature
-----------------
I think nobody wants to update their application to a change like this, also because it would imply having to propagate the vars deeper into application code, util functions, etc. that currently use the profies.
It may be very difficult to do this in a way that existing overridden code will not fail and will show a deprecation warning.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
I think nobody wants to update their application to a change like this, also because it would imply having to propagate the vars deeper into application code, util functions, etc. that currently use the profies.
It may be very difficult to do this in a way that existing overridden code will not fail and will show a deprecation warning.
What Broke
Performance issues during request dispatching due to context proxy access.
Why It Broke
Flask methods were accessing context proxies instead of passing AppContext directly
Fix Options (Details)
Option A — Apply the official fix
The current AppContext object is passed through the various request dispatch methods, rather than each method accessing the proxies. This change improves performance and compatibility during a deprecation period.
Fix reference: https://github.com/pallets/flask/pull/5818
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not suitable for applications heavily relying on the old method signatures.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
- Pin production dependencies and upgrade only with a reproducible test that hits the failing path.
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.