Exception in ASGI application with newest Fastapi

See original GitHub issue

I’ve successfully used the Fullstack fastapi template in the past. With the recent version of fastapi installed through the Dockerfile, I get the following error when I log on to docker-compose logs -f backend and open up **https://localhost/**:

backend_1        | INFO: ('172.22.0.2', 39320) - "GET /api/v1/users/me HTTP/1.1" 500
backend_1        | ERROR: Exception in ASGI application
backend_1        | Traceback (most recent call last):
backend_1        |   File "/usr/local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 368, in run_asgi
backend_1        |     result = await app(self.scope, self.receive, self.send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/applications.py", line 133, in __call__
backend_1        |     await self.error_middleware(scope, receive, send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 122, in __call__
backend_1        |     raise exc from None
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/errors.py", line 100, in __call__
backend_1        |     await self.app(scope, receive, _send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/base.py", line 25, in __call__
backend_1        |     response = await self.dispatch_func(request, self.call_next)
backend_1        |   File "./app/main.py", line 34, in db_session_middleware
backend_1        |     response = await call_next(request)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/base.py", line 45, in call_next
backend_1        |     task.result()
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/base.py", line 38, in coro
backend_1        |     await self.app(scope, receive, send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/middleware/cors.py", line 76, in __call__
backend_1        |     await self.app(scope, receive, send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 73, in __call__
backend_1        |     raise exc from None
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/exceptions.py", line 62, in __call__
backend_1        |     await self.app(scope, receive, sender)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 585, in __call__
backend_1        |     await route(scope, receive, send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 207, in __call__
backend_1        |     await self.app(scope, receive, send)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/starlette/routing.py", line 40, in app
backend_1        |     response = await func(request)
backend_1        |   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 122, in app
backend_1        |     skip_defaults=response_model_skip_defaults,
backend_1        |   File "/usr/local/lib/python3.7/site-packages/fastapi/routing.py", line 54, in serialize_response
backend_1        |     raise ValidationError(errors)
backend_1        | pydantic.error_wrappers.ValidationError: 1 validation error
backend_1        | response
backend_1        |   value is not a valid dict (type=type_error.dict)

There’s a small chance that this error relates to some code edits I have introduced, but I suspect this is related to the latest changes to how pydantic validates models in newer Fastapi versions. Anyone else experiencing this? I haven’t tested it with a fresh full-stack-fastapi-postgresql, but will check as soon as possible…

Just a note: login still works, perhaps this is just a backend error with no consequences, it is still annoying seeing this error every time the login screen is requested.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
jf---commented, Aug 16, 2019

@Sieboldianus I ran into this issue, it still comes up running the current master. Can I suggest to keep this issue open until #43 is closed?

1reaction
tiangolocommented, Apr 12, 2020

Thanks for the report and discussion here everyone!

This should be fixed in the current master. 🎉 🚀

So I guess we could close this issue, right @Sieboldianus ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

FastAPI and Pydantic RecursionError Causing Exception in ...
ERROR: Exception in ASGI application. Simply means one or more of the .py files have not been saved before trying to test/run.
Read more >
Advanced Middleware - FastAPI
In general, ASGI middlewares are classes that expect to receive an ASGI app as the first argument. But FastAPI (actually Starlette) provides a...
Read more >
tiangolo/fastapi - Gitter
Hi, I'm very new to FastAPI. Thanks for your work! I am trying to handle a 302 to allow the user to complete...
Read more >
Get Internal server error & Uvicorn server error when upload ...
The upload model showed not found at browser. This issue ooccurred at both Pytorch & Triton backend and let me can't upload the...
Read more >
Problem after installing new package - General - Docker Forums
ERROR: Exception in ASGI application Traceback (most recent call ... File "/usr/local/lib/python3.8/site-packages/fastapi/applications.py", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found