The Fix
Upgrade to version 0.15.0 or later.
Based on closed encode/httpx issue #1227 · PR/commit linked
@@ -1,6 +1,15 @@
@@ -1,6 +1,15 @@
import inspect
-import typing
from json import dumps as json_dumps
+from typing import (
Option A — Upgrade to fixed release\nUpgrade to version 0.15.0 or later.\nWhen NOT to use: This fix should not be used if backward compatibility with existing Response instantiation is critical.\n\n
Why This Fix Works in Production
- Trigger: * Make the `request` parameter become optional. Have a `.request` property that returns a `Request` instance or raises a RuntimeError if the instance is not…
- Mechanism: The Response class required mandatory parameters that limited instantiation flexibility
- Why the fix works: Adds support for instantiating Response instances directly with parameters like text, html, and json, addressing issue #1227. (first fixed release: 0.15.0).
Why This Breaks in Prod
- The Response class required mandatory parameters that limited instantiation flexibility
- Production symptom (often without a traceback): * Make the `request` parameter become optional. Have a `.request` property that returns a `Request` instance or raises a RuntimeError if the instance is not set. Have a property setter for the `.request` property.
Proof / Evidence
- GitHub issue: #1227
- Fix PR: https://github.com/encode/httpx/pull/1297
- First fixed release: 0.15.0
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.75
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.79
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“If any contributors want to take a go at this I'd suggest approaching it in parts..”
“Great. Definitely treat each of those items in isolation as separate PRs. 😀”
“The issue is quite detailed thanks for that. 😄 I don't have much experience with httpx but would love to give it a try.”
Failure Signature (Search String)
- * Make the `request` parameter become optional. Have a `.request` property that returns a `Request` instance or raises a RuntimeError if the instance is not set. Have a property
Copy-friendly signature
Failure Signature
-----------------
* Make the `request` parameter become optional. Have a `.request` property that returns a `Request` instance or raises a RuntimeError if the instance is not set. Have a property setter for the `.request` property.
Error Message
Signature-only (no traceback captured)
Error Message
-------------
* Make the `request` parameter become optional. Have a `.request` property that returns a `Request` instance or raises a RuntimeError if the instance is not set. Have a property setter for the `.request` property.
What Broke
Unit tests for custom auth classes were difficult to implement due to rigid Response instantiation.
Why It Broke
The Response class required mandatory parameters that limited instantiation flexibility
Fix Options (Details)
Option A — Upgrade to fixed release Safe default (recommended)
Upgrade to version 0.15.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/encode/httpx/pull/1297
First fixed release: 0.15.0
Last verified: 2026-02-09. Validate in your environment.
When NOT to Use This Fix
- This fix should not be used if backward compatibility with existing Response instantiation is critical.
Did This Fix Work in Your Case?
Quick signal helps us prioritize which fixes to verify and improve.
Prevention
- Add a CI check that diffs key outputs after upgrades (OpenAPI schema snapshots, JSON payload shapes, CLI output).
- Upgrade behind a canary and run integration tests against the canary before 100% rollout.
Version Compatibility Table
| Version | Status |
|---|---|
| 0.15.0 | Fixed |
Related Issues
No related fixes found.
Sources
We don’t republish the full GitHub discussion text. Use the links above for context.