The Fix
Upgrade to version 2.0.0 or later.
Based on closed pallets/flask issue #3776 · 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%.
@@ -60,6 +60,9 @@ Unreleased
- ``helpers.safe_join`` is deprecated. Use
``werkzeug.utils.safe_join`` instead. :pr:`3828`
+- The request context does route matching before opening the session.
+ This could allow a session interface to change behavior based on
+ ``request.endpoint``. :issue:`3776`
Option A — Upgrade to fixed release\nUpgrade to version 2.0.0 or later.\nWhen NOT to use: This fix should not be used if the application relies on the previous session behavior.\n\n
Why This Fix Works in Production
- Trigger: Our SessionInterface subclass looks at `request.endpoint` to determine if it should open a new session - opening a new is only appropriate on some endpoints…
- Mechanism: The request context does not perform route matching before opening the session
- Why the fix works: Ensures that the session_interface.open_session is called after URL matching, allowing access to request.endpoint. (first fixed release: 2.0.0).
- 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
- The request context does not perform route matching before opening the session
- Production symptom (often without a traceback): Our SessionInterface subclass looks at `request.endpoint` to determine if it should open a new session - opening a new is only appropriate on some endpoints. Now this is always `None`, so it cannot make this distinction anymore.
Proof / Evidence
- GitHub issue: #3776
- Fix PR: https://github.com/pallets/flask/pull/3794
- First fixed release: 2.0.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-08
- Confidence: 0.85
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.69
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“Added a PR here which is simple enough - URL matching was happening immediately after session creation, now it happens immediately after.”
Failure Signature (Search String)
- Our SessionInterface subclass looks at `request.endpoint` to determine if it should open a new session - opening a new is only appropriate on some endpoints. Now this is always
Copy-friendly signature
Failure Signature
-----------------
Our SessionInterface subclass looks at `request.endpoint` to determine if it should open a new session - opening a new is only appropriate on some endpoints. Now this is always `None`, so it cannot make this distinction anymore.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Our SessionInterface subclass looks at `request.endpoint` to determine if it should open a new session - opening a new is only appropriate on some endpoints. Now this is always `None`, so it cannot make this distinction anymore.
What Broke
SessionInterface cannot determine if a new session should be opened, leading to incorrect session handling.
Why It Broke
The request context does not perform route matching before opening the session
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 2.0.0 or later.
Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.
Fix reference: https://github.com/pallets/flask/pull/3794
First fixed release: 2.0.0
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if the application relies on the previous session behavior.
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.
Version Compatibility Table
| Version | Status |
|---|---|
| 2.0.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.