Jump to solution
Verify

The Fix

Upgrade to version 0.18.0 or later.

Based on closed Kludex/starlette issue #1355 · 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
@@ -276,7 +276,10 @@ def __init__( self.name = get_name(endpoint) if name is None else name - if inspect.isfunction(endpoint) or inspect.ismethod(endpoint): + endpoint_handler = endpoint + while isinstance(endpoint_handler, functools.partial):
repro.py
import functools from starlette.applications import Starlette from starlette.routing import WebSocketRoute async def handle_ws(ws): pass app = Starlette(debug=True, routes=[ WebSocketRoute("/", functools.partial(handle_ws)), ])
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.18.0 or later.\nWhen NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.\n\n

Why This Fix Works in Production

  • Trigger: result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
  • Mechanism: Adds support for using functools.partial with WebSocketRoute, fixing a TypeError when accessing a WebSocketRoute with a function wrapped in functools.partial.
  • Why the fix works: Adds support for using functools.partial with WebSocketRoute, fixing a TypeError when accessing a WebSocketRoute with a function wrapped in functools.partial. (first fixed release: 0.18.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.9 in real deployments (not just unit tests).
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #1355
  • Fix PR: https://github.com/kludex/starlette/pull/1356
  • First fixed release: 0.18.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.36

Discussion

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

“### Checklist - [x] The bug is reproducible against the latest release and/or master. - [x] There are no similar issues or pull requests to fix it yet. ### Describe the bug Accessing a WebSocketRoute with async function wrapped in functools”
Issue thread · issue description · source

Failure Signature (Search String)

  • result = await self.app(self.scope, self.asgi_receive, self.asgi_send)

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "/tmp/bug/venv/lib/python3.9/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 199, in run_asgi result = await self.app(self.scope, self.asgi_receive, self.asgi_send) File "/tmp/bug/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__ return await self.app(scope, receive, send) File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__ await self.middleware_stack(scope, receive, send) File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 146, in __call__ await self.app(scope, receive, send) File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/exceptions.py", line 58, in __call__ await self.app(scope, receive, send) File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/routing.py", line 656, in __call__ await route.handle(scope, receive, send) File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/routing.py", line 315, in handle await self.app(scope, receive, send) TypeError: handle_ws() takes 1 positional argument but 3 were given

Minimal Reproduction

repro.py
import functools from starlette.applications import Starlette from starlette.routing import WebSocketRoute async def handle_ws(ws): pass app = Starlette(debug=True, routes=[ WebSocketRoute("/", functools.partial(handle_ws)), ])

Environment

  • Python: 3.9

Fix Options (Details)

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

Upgrade to version 0.18.0 or later.

When NOT to use: Do not use if it changes public behavior or if the failure cannot be reproduced.

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

Fix reference: https://github.com/kludex/starlette/pull/1356

First fixed release: 0.18.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

  • Do not use if it changes public behavior or if the failure cannot be reproduced.

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

  • 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

VersionStatus
0.18.0 Fixed

Related Issues

No related fixes found.

Sources

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