You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by fraser-langton December 6, 2022
From issue in FastAPI - issue was said to be from starlette
Was initially noticed in FastAPI 0.74.0, was fixed after 0.79.0 but has since regressed (FastAPI 0.88.0 it isn't working)
When exceptions are raised on a subapp, the exceptions are not propagated all the way to see in console
In the example code
/info raises an exception and the full stacktrace is seen in console
/private/info does not raise the exception and only INFO: 127.0.0.1:56308 - "GET /info HTTP/1.1" 500 Internal Server Error is shown in console
importuvicornfromfastapiimportFastAPIfromstarlette.middleware.baseimportBaseHTTPMiddlewareapp=FastAPI()
@app.get("/info")definfo():
# raises Exception as expected, the traceback is seen in consoleraiseExceptionprivate_api=FastAPI()
@private_api.get("/info")definfo():
# exception is handled silently, no traceback is seen in consoleraiseExceptionapp.mount("/private", private_api)
classMiddleware(BaseHTTPMiddleware):
asyncdefdispatch(self, request, call_next):
returnawaitcall_next(request)
app.add_middleware(Middleware) # when this is removed, the exceptions are raised for all routesif__name__=='__main__':
uvicorn.run(app, port=8000)
The text was updated successfully, but these errors were encountered:
I'm experiencing this issue as well since the upgrade to starlette >= 0.28. I suspect this is linked to #2026?
I just ran the example above for those two cases:
starlette 0.36.3, fastapi 0.109.2: silently fails and only prints INFO: 127.0.0.1:51560 - "GET /private/info HTTP/1.1" 500 Internal Server Error to the console
starlette 0.27.0, fastapi 0.104.1: prints full traceback INFO: 127.0.0.1:52001 - "GET /info HTTP/1.1" 500 Internal Server Error, ERROR: Exception in ASGI application, Traceback (most recent call last): ...
I note that in the second case, the INFO logger does not show the full path (/private/info). I'm not sure why, but I was for sure sending a request to /private/info.
Discussed in #1976
Originally posted by fraser-langton December 6, 2022
From issue in FastAPI - issue was said to be from starlette
Was initially noticed in FastAPI 0.74.0, was fixed after 0.79.0 but has since regressed (FastAPI 0.88.0 it isn't working)
When exceptions are raised on a subapp, the exceptions are not propagated all the way to see in console
In the example code
/info raises an exception and the full stacktrace is seen in console
/private/info does not raise the exception and only
INFO: 127.0.0.1:56308 - "GET /info HTTP/1.1" 500 Internal Server Error
is shown in consoleThe text was updated successfully, but these errors were encountered: