The Fix
Upgrade to version 2.0.0 or later.
Based on closed pallets/flask issue #3628 · PR/commit linked
Production note: This usually shows up under retries/timeouts. Treat it as a side-effect risk until you can verify behavior with a canary + real traffic.
@@ -27,9 +27,14 @@ Unreleased
- When specifying a factory function with ``FLASK_APP``, keyword
argument can be passed. :issue:`3553`
-- When loading a ``.env`` or ``.flaskenv`` file on top level directory,
- Flask will not change current work directory to the location of dotenv
- files, in order to prevent potential confusion. :pr:`3560`
from flask import Flask
app = Flask(__name__)
@app.route('/')
def issue():
return {'test': 'test'}, {'Content-Type': 'test'}
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 2.0.0 or later.\nWhen NOT to use: This fix is not applicable if the application intentionally requires duplicate headers.\n\n
Why This Fix Works in Production
- Trigger: Returning Response and headers causes duplicate headers
- Mechanism: The issue arises from jsonify adding a 'Content-Type' header while make_response extends existing headers
- Why the fix works: Changed `make_response` to use `headers.update` instead of `headers.extend`, resolving the issue of duplicate headers. (first fixed release: 2.0.0).
- If left unfixed, retries/timeouts can trigger duplicate external side-effects (double charges, duplicate emails, repeated writes).
Why This Breaks in Prod
- The issue arises from jsonify adding a 'Content-Type' header while make_response extends existing headers
- Production symptom (often without a traceback): Returning Response and headers causes duplicate headers
Proof / Evidence
- GitHub issue: #3628
- Fix PR: https://github.com/pallets/flask/pull/3684
- 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.63
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I don't know if we should change this behavior, but if you want to set the default mimetype (e.g. Content-Type value) for JSON response, you…”
“I don't think he wants to change it globally. Since duplicate content-type headers make no sense I think it's reasonable to take the one from…”
“@greyli thanks, we need to support multiple different content-types for JSON in the same app. I think this is pretty common for production APIs that…”
“Before we do anything, I want to understand why headers are extended rather than appended right now”
Failure Signature (Search String)
- Returning Response and headers causes duplicate headers
- Using `curl -v http://127.0.0.1:5000/` to query the view I expect only one `Content-Type` header > `Content-Type: test`
Copy-friendly signature
Failure Signature
-----------------
Returning Response and headers causes duplicate headers
Using `curl -v http://127.0.0.1:5000/` to query the view I expect only one `Content-Type` header > `Content-Type: test`
Error Message
Signature-only (no traceback captured)
Error Message
-------------
Returning Response and headers causes duplicate headers
Using `curl -v http://127.0.0.1:5000/` to query the view I expect only one `Content-Type` header > `Content-Type: test`
Minimal Reproduction
from flask import Flask
app = Flask(__name__)
@app.route('/')
def issue():
return {'test': 'test'}, {'Content-Type': 'test'}
What Broke
Duplicate headers are returned in HTTP responses, causing potential client confusion.
Why It Broke
The issue arises from jsonify adding a 'Content-Type' header while make_response extends existing headers
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/3684
First fixed release: 2.0.0
Last verified: 2026-02-08. Validate in your environment.
When NOT to Use This Fix
- This fix is not applicable if the application intentionally requires duplicate headers.
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 |
|---|---|
| 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.