Describe the bug
The latest release of Starlette 0.12.13 introduced a breaking change to the way it initialises the core Starlette class which is incompatible with FastAPI's use (lack of use of super()). Introduced by this change: https://github.com/encode/starlette/commit/91eefb2af3940364b051138bed47319e189d31be
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Fast API server starts
Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
Now in fastapi pinned the 0.12.9 version. I think it isn't bug (at least in current release).
The latest release of Starlette 0.12.13
I think the breakage is happening on v0.13, not v0.12.13. Here's the traceback I've got on Starlette v0.13 / FastAPI v0.42:
# app.py
from fastapi import FastAPI
app = FastAPI()
$ python app.py
email-validator not installed, email fields will be treated as str.
To install, run: pip install email-validator
Traceback (most recent call last):
File "app.py", line 3, in <module>
app = FastAPI()
File "/Users/florimond/Developer/datadog-projects/ddtrace-asgi/venv/lib/python3.8/site-packages/fastapi/applications.py", line 78, in __init__
self.setup()
File "/Users/florimond/Developer/datadog-projects/ddtrace-asgi/venv/lib/python3.8/site-packages/fastapi/applications.py", line 130, in setup
self.add_exception_handler(HTTPException, http_exception_handler)
File "/Users/florimond/Developer/datadog-projects/ddtrace-asgi/venv/lib/python3.8/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'
But I agree with @prostomarkeloff — FastAPI v0.42 seems to be pinned to Starlette v0.12.9, so I'm not getting this error unless I forcefully install Starlette v0.13.
Thanks @prostomarkeloff and @florimondmanca for the help! :bowing_man: :clap:
Yeah @Chippiewill , that would be a feature request to update FastAPI to support the latest Starlette (that I will) rather than a bug.
Starlette 0.12.12 is safe to use with FastAPI, this bug only occurs under 0.12.13 and latter.
Now that FastAPI supports the latest Starlette (since version 0.50.0), may we close this issue @Chippiewill ?
Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.
Most helpful comment
Now in fastapi pinned the
0.12.9version. I think it isn't bug (at least in current release).