Fastapi: [BUG] FastAPI throw 'exception_handlers' attribute error

Created on 15 Nov 2019  路  4Comments  路  Source: tiangolo/fastapi

Describe the bug
FastAPI is incompatible with Startlette handling error. The error is that 'FastAPI' object has no attribute 'exception_handlers'.
Here the trace error:

File "/app/soarapi/app.py", line 72, in <module>
    application = app = FastAPI()
File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 78, in __init__
    self.setup()
File "/usr/local/lib/python3.7/site-packages/fastapi/applications.py", line 130, in setup
    self.add_exception_handler(HTTPException, http_exception_handler)
File "/usr/local/lib/python3.7/site-packages/starlette/applications.py", line 124, in add_exception_handler
    self.exception_handlers[exc_class_or_status_code] = handler
AttributeError: 'FastAPI' object has no attribute 'exception_handlers'

To Reproduce
Just run the tutorial to reproduce the error: docs/handling_errors/tutorial004.py

Expected behavior
I expected that the exception_handler interface worked similar as Starlette.

Screenshots
no

Environment:

  • OS: Linux - Ubuntu
  • FastAPI Version: 0.42.0
  • Python version: 3.7
  • Starlette Version: 0.13.0
bug

Most helpful comment

I read about FastAPI deps and it compatible with Starlette 0.12.9.

All 4 comments

I read about FastAPI deps and it compatible with Starlette 0.12.9.

Please reopen this issue as this issue persists with the latest version of starlette

Hi when is FastAPI planning to support the latest version of Starlette? I am getting errors for anything greater than 0.12.11

Thanks for reporting back and closing the issue @nielsonsantana :+1:


FastAPI supports Starlette 0.13.2 since version 0.50.0 (we're at version 0.54.1 now).

Was this page helpful?
0 / 5 - 0 ratings