# RuntimeError: 没有返回响应。

- **ID:** `python/starlette-streaming-response-generator-error`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

中间件或依赖返回 None 而非 Response，或路由忘记 return，导致 Starlette 找不到可发送的响应。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (92% 成功率)
   ```
   Ensure every code path returns a Response:
return JSONResponse({'ok': True})
   ```
2. **** (88% 成功率)
   ```
   In middleware, always call await call_next(request) and return its result.
   ```

## 无效尝试

- **** — The error is raised at the ASGI layer where the handler may not apply. (70% 失败率)
- **** — Masks the real bug; the route still doesn't produce intended output. (75% 失败率)
