python
runtime_error
ai_generated
true
RuntimeError: 没有返回响应。
RuntimeError: No response returned.
ID: python/starlette-streaming-response-generator-error
80%修复率
84%置信度
0证据数
2024-09-25首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
中间件或依赖返回 None 而非 Response,或路由忘记 return,导致 Starlette 找不到可发送的响应。
English
A middleware or dependency returns None instead of a Response, or a route forgets to return, so Starlette finds no response to send.
解决方案
-
92% 成功率
Ensure every code path returns a Response: return JSONResponse({'ok': True}) -
88% 成功率
In middleware, always call await call_next(request) and return its result.
无效尝试
常见但无效的做法:
-
70% 失败
The error is raised at the ASGI layer where the handler may not apply.
-
75% 失败
Masks the real bug; the route still doesn't produce intended output.