TypeError using SentryAsgiMiddleware with FastAPI/Starlette app
See original GitHub issueI cannot get SentryAsgiMiddleware
to work with our FastAPI app. We tried to follow the example in the Sentry docs, so the app module basically looks like this:
from fastapi import FastAPI
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
...
app = FastAPI()
@app.post()
...
app = SentryAsgiMiddleware(app)
This gives an error on all requests, see the following stack trace:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 385, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/usr/local/lib/python3.7/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.7/site-packages/uvicorn/middleware/asgi2.py", line 7, in __call__
await instance(receive, send)
File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/asgi.py", line 54, in run_asgi2
scope, lambda: self.app(scope)(receive, send)
File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/asgi.py", line 93, in _run_app
raise exc from None
File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/asgi.py", line 90, in _run_app
return await callback()
File "/usr/local/lib/python3.7/site-packages/sentry_sdk/integrations/asgi.py", line 54, in <lambda>
scope, lambda: self.app(scope)(receive, send)
TypeError: __call__() missing 2 required positional arguments: 'receive' and 'send'
Library versions:
- python==3.7.5
- sentry-sdk==0.13.2
- uvicorn==0.10.8
- fastapi==0.42.0
- starlette==0.12.9
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Advanced Middleware - FastAPI
As FastAPI is based on Starlette and implements the ASGI specification, you can use any ASGI middleware. A middleware doesn't have to be...
Read more >tiangolo/fastapi - Gitter
Hey guys,. I'm developing a FastAPI app and was experimenting with Celery as a task queue. However, it seems that it often just...
Read more >Python and FastAPI: keep getting 405 when posting response
First, you need to change request in the lectio_root resp = requests.post(url, data=payload, headers=headers). to resp = requests.get(url, ...
Read more >Introducing Starlite: A New Python Asynchronous API ...
The idea to use Starlette and pydantic as bases is of course not new - it ... from typing import Optional from fastapi...
Read more >ASGI - Sentry Documentation
Learn about using Sentry with ASGI applications. ... If you use an ASGI framework, please use our specific integrations for FastAPI, Starlette, Sanic, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
0.13.3 has been released, sorry for the delay
@Stigjb sometime this week