Jump to solution
Verify

The Fix

Upgrade to version 0.13.0 or later.

Based on closed encode/httpx issue #879 · 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
@@ -38,6 +38,13 @@ :members: headers cookies params request get head options post put patch delete build_request send close +## `AsyncClient` + +::: httpx.AsyncClient
repro.py
import httpx from fastapi import FastAPI app = FastAPI() @app.get("/users/{user_id}") async def read_user(user_id: str): return {'user_id': user_id} with httpx.Client(app=app) as client: response = client.get("http://www.example.com/users/foo")
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\nUpgrade to version 0.13.0 or later.\nWhen NOT to use: This fix is not applicable if you intend to use an ASGI app with the sync client.\n\n

Why This Fix Works in Production

  • Trigger: response = client.get("http://www.example.com/users/foo")
  • Mechanism: The sync client incorrectly documented support for ASGI apps instead of WSGI apps
  • Why the fix works: Updated the Client docstring to clarify that it takes a WSGI app instead of an ASGI app, and added the AsyncClient API to the documentation. (first fixed release: 0.13.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

  • Shows up under Python 3.7 in real deployments (not just unit tests).
  • The sync client incorrectly documented support for ASGI apps instead of WSGI apps
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #879
  • Fix PR: https://github.com/encode/httpx/pull/883
  • First fixed release: 0.13.0
  • 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.45

Discussion

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

“I went ahead and updated the issue description”
@florimondmanca · 2020-03-28 · source
“Hi Ed! This is actually expected behavior”
@florimondmanca · 2020-03-28 · source
“Thanks for the quick response on this”
@Singletoned · 2020-03-28 · source

Failure Signature (Search String)

  • response = client.get("http://www.example.com/users/foo")

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "temp.py", line 12, in <module> response = client.get("http://www.example.com/users/foo") File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_client.py", line 714, in get timeout=timeout, File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_client.py", line 571, in request request, auth=auth, allow_redirects=allow_redirects, timeout=timeout, File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_client.py", line 591, in send request, auth=auth, timeout=timeout, allow_redirects=allow_redirects, File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_client.py", line 618, in send_handling_redirects request, auth=auth, timeout=timeout, history=history File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_client.py", line 654, in send_handling_auth response = self.send_single_request(request, timeout) File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_client.py", line 678, in send_single_request response = dispatcher.send(request, timeout=timeout) File "/Users/singletoned/.envs/testino/lib/python3.7/site-packages/httpx/_dispatch/wsgi.py", line 90, in send result = self.app(environ, start_response) TypeError: __call__() missing 1 required positional argument: 'send'

Minimal Reproduction

repro.py
import httpx from fastapi import FastAPI app = FastAPI() @app.get("/users/{user_id}") async def read_user(user_id: str): return {'user_id': user_id} with httpx.Client(app=app) as client: response = client.get("http://www.example.com/users/foo")

Environment

  • Python: 3.7

What Broke

Using an ASGI app with the sync client results in a TypeError during request handling.

Why It Broke

The sync client incorrectly documented support for ASGI apps instead of WSGI apps

Fix Options (Details)

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

Upgrade to version 0.13.0 or later.

When NOT to use: This fix is not applicable if you intend to use an ASGI app with the sync client.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Fix reference: https://github.com/encode/httpx/pull/883

First fixed release: 0.13.0

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 you intend to use an ASGI app with the sync client.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

Verify Fix

verify
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

  • 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.
  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
0.13.0 Fixed

Related Issues

No related fixes found.

Sources

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