python runtime_error ai_generated true

RuntimeError: 没有返回响应。

RuntimeError: No response returned.

ID: python/starlette-streaming-response-generator-error

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 70% 失败

    The error is raised at the ASGI layer where the handler may not apply.

  2. 75% 失败

    Masks the real bug; the route still doesn't produce intended output.