Repository navigation
WSGITransport ignores raise_app_exceptions=False when the app raises #3881
Replies: 1 comment
|
One regression case worth adding is a generator that calls def render_body():
raise RuntimeError('body generation failed')
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield render_body()Replacing OpenAI Codex assisted with reproducing and drafting this example. |
Uh oh!
There was an error while loading. Please reload this page.
WSGITransport(raise_app_exceptions=False)only suppresses exceptions that arrive throughstart_response(..., exc_info). If the WSGI application raises directly, the exception still propagates out of the client, so the documented behaviour ("Inspect 500 error responses rather than raise exceptions by settingraise_app_exceptions=False",docs/advanced/transports.md) holds only for one of the two ways an application can fail.ASGITransportreturns a500for the same application — #2669 added that, withtests/test_asgi.py::test_asgi_exc_no_raise— so the two transports disagree on the same switch, and the WSGI side has no equivalent test.The fix would mirror the ASGI handling: wrap the application call, re-raise when
raise_app_exceptions=True, and otherwise fall back to a 500 with an empty body, keeping the status already passed tostart_response()if there was one. Happy to send a PR with tests if that's the behaviour you want — opening this first as the contributing guide asks.All reactions