python
runtime_error
ai_generated
true
RuntimeError: 未返回响应。
RuntimeError: No response returned.
ID: python/starlette-runtimeerror-no-response-returned
80%修复率
84%置信度
0证据数
2024-09-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
ASGI 中间件或端点返回 None 而非 Response,或异常在 BaseHTTPMiddleware 的 dispatch 中被吞掉。
English
An ASGI middleware or endpoint returns None instead of a Response, or an exception is swallowed inside a BaseHTTPMiddleware dispatch.
解决方案
-
93% 成功率
class M(BaseHTTPMiddleware): async def dispatch(self, request, call_next): response = await call_next(request) return response -
90% 成功率
try: response = await call_next(request) except Exception: raise
无效尝试
常见但无效的做法:
-
75% 失败
Hides the original exception and breaks streaming responses.
-
80% 失败
Behavior persists across versions; root cause is the middleware logic.