python runtime_error ai_generated true

RuntimeError: No response returned.

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-09-25First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active — — —

Root Cause

A middleware or dependency returns None instead of a Response, or a route forgets to return, so Starlette finds no response to send.

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 70% fail

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

  2. 75% fail

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