The Fix
Upgrade to version 3.1.2 or later.
Based on closed pallets/flask issue #5729 · 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%.
@@ -5,6 +5,8 @@ Unreleased
- Drop support for Python 3.9. :pr:`5730`
- Remove previously deprecated code: ``__version__``. :pr:`5648`
+- ``template_filter``, ``template_test``, and ``template_global`` decorators
+ can be used without parentheses. :issue:`5729`
from flask import Flask, render_template_string
app = Flask(__name__)
@app.template_filter
def double(x):
return x * 2
@app.route("/")
def index():
return render_template_string("2 times 2 is {{ 2 | double }}")
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
Option A — Upgrade to fixed release\nUpgrade to version 3.1.2 or later.\nWhen NOT to use: This fix is not applicable if the decorator's behavior without parentheses is intended.\n\n
Why This Fix Works in Production
- Trigger: jinja2.exceptions.TemplateAssertionError: No filter named 'double'.
- Mechanism: The template_filter decorator fails to register without parentheses
- Why the fix works: Enhances the App.template_filter decorator to support being called without parentheses, while maintaining backward compatibility. (first fixed release: 3.1.2).
- 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
- Shows up under Python 3.11.11 in real deployments (not just unit tests).
- The template_filter decorator fails to register without parentheses
- Surfaces as: jinja2.exceptions.TemplateAssertionError: No filter named 'double'.
Proof / Evidence
- GitHub issue: #5729
- Fix PR: https://github.com/pallets/flask/pull/5736
- First fixed release: 3.1.2
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.85
- 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).
“@alexwlchan is it okay if i take up this issue? I understand from https://palletsprojects.com/contributing that I don't have to ask first but I thought it…”
“Not the author of the issue (not sure why you pinged him) but a maintainer: Yes sure, feel free to work on it. PRs to…”
“Hi there! I'm keen to start contributing to Flask and this issue caught my eye”
“There's already a draft PR for this... why do you want to start working on yet another one while there's an open PR? :)”
Failure Signature (Search String)
- jinja2.exceptions.TemplateAssertionError: No filter named 'double'.
Error Message
Stack trace
Error Message
-------------
jinja2.exceptions.TemplateAssertionError: No filter named 'double'.
Minimal Reproduction
from flask import Flask, render_template_string
app = Flask(__name__)
@app.template_filter
def double(x):
return x * 2
@app.route("/")
def index():
return render_template_string("2 times 2 is {{ 2 | double }}")
Environment
- Python: 3.11.11
What Broke
Users encounter a TemplateAssertionError when using the filter without parentheses.
Why It Broke
The template_filter decorator fails to register without parentheses
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 3.1.2 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/5736
First fixed release: 3.1.2
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the decorator's behavior without parentheses is intended.
Verify Fix
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
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 |
|---|---|
| 3.1.2 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.