# RuntimeError: 未返回响应。

- **ID:** `python/starlette-runtimeerror-no-response-returned`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

ASGI 中间件或端点返回 None 而非 Response，或异常在 BaseHTTPMiddleware 的 dispatch 中被吞掉。

## 版本兼容性

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

## 解决方案

1. **** (93% 成功率)
   ```
   class M(BaseHTTPMiddleware):
    async def dispatch(self, request, call_next):
        response = await call_next(request)
        return response
   ```
2. **** (90% 成功率)
   ```
   try:
    response = await call_next(request)
except Exception:
    raise
   ```

## 无效尝试

- **** — Hides the original exception and breaks streaming responses. (75% 失败率)
- **** — Behavior persists across versions; root cause is the middleware logic. (80% 失败率)
