python
runtime_error
ai_generated
true
RuntimeError: No response returned.
ID: python/starlette-no-response-returned
80%Fix Rate
85%Confidence
0Evidence
2024-04-03First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 0.30.x | active | — | — | — |
| 0.36.x | active | — | — | — |
Root Cause
A middleware or endpoint returned None instead of a Response, or an exception was swallowed without a response.
generic中文
中间件或端点返回了None而不是Response,或者异常被吞掉且未返回响应。
Workarounds
-
92% success
async def mw(request, call_next):\n try:\n return await call_next(request)\n except Exception:\n return JSONResponse({'err': 'x'}, status_code=500) -
95% success
@app.get('/')\nasync def r():\n return JSONResponse({})
Dead Ends
Common approaches that don't work:
-
90% fail
Swallowing exceptions leaves no response; error persists.
-
60% fail
Raises the original error but does not produce a Response.