Jump to solution
Verify

The Fix

Upgrade to version 0.15.4 or later.

Based on closed encode/httpx issue #1323 · 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%.

Jump to Verify Open PR/Commit
@@ -900,7 +900,7 @@ def __init__( self._prepare(headers) self.stream = stream - if content is None or isinstance(content, bytes): + if content is None or isinstance(content, (bytes, str)): # Load the response body, except for streaming content.
repro
import httpx r = httpx.Response(200, content='content') result = r.json()
verify
Follow the reproduction steps, confirm the failure, apply the fix, and repeat the same steps to verify the behavior changes.
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.15.4 or later.\nWhen NOT to use: This fix is not applicable if using non-string content types.\n\n

Why This Fix Works in Production

  • Trigger: Response behaviour has been changed since 0.15.0, so that calling json() on response instance raises ResponseNotRead exception.
  • Mechanism: Response instances created with content=<str> did not automatically read the response body
  • Why the fix works: Fixes the issue where Response instances created with content=<str> did not automatically read the response body. (first fixed release: 0.15.4).
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

  • Response instances created with content=<str> did not automatically read the response body
  • Production symptom (often without a traceback): Response behaviour has been changed since 0.15.0, so that calling json() on response instance raises ResponseNotRead exception.

Proof / Evidence

  • GitHub issue: #1323
  • Fix PR: https://github.com/encode/httpx/pull/1324
  • First fixed release: 0.15.4
  • 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.73

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Thanks for raising this, yup”
@lovelydinosaur · 2020-09-25 · confirmation · source

Failure Signature (Search String)

  • Response behaviour has been changed since 0.15.0, so that calling json() on response instance raises ResponseNotRead exception.
Copy-friendly signature
signature.txt
Failure Signature ----------------- Response behaviour has been changed since 0.15.0, so that calling json() on response instance raises ResponseNotRead exception.

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Response behaviour has been changed since 0.15.0, so that calling json() on response instance raises ResponseNotRead exception.

Minimal Reproduction

  1. import httpx
  2. r = httpx.Response(200, content='content')
  3. result = r.json()

What Broke

Calling json() on response raises ResponseNotRead exception, causing application errors.

Why It Broke

Response instances created with content=<str> did not automatically read the response body

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

Upgrade to version 0.15.4 or later.

When NOT to use: This fix is not applicable if using non-string content types.

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/1324

First fixed release: 0.15.4

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if using non-string content types.

Verify Fix

verify
Follow the reproduction steps, confirm the failure, apply the fix, and repeat the same steps to verify the behavior changes.

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.
  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

VersionStatus
0.15.4 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.