Jump to solution
Details

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%.

Open PR/Commit
@@ -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`
fix.md
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).
Production impact:
  • 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.”
@mbpreble · 2020-10-17 · source

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
signature.txt
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.txt
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.

When NOT to use: This fix should not be used if the application relies on the previous session behavior.

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.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

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

VersionStatus
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.