Skip to content

FastAPI Integration - TypeError: 'coroutine' object is not callable #1514

@danilogco

Description

@danilogco

How do you use Sentry?

Self-hosted/on-premise

Version

1.8.0

Steps to Reproduce

  1. Install the lib v1.8.0;
  2. Our Sentry server is self-hosted;
  3. Configure the sentry inicialization as described in the release documentation:
from fastapi import FastAPI
from sentry_sdk.integrations.starlette import StarletteIntegration
from sentry_sdk.integrations.fastapi import FastApiIntegration
sentry_sdk.init(
dsn="...",
integrations=[StarletteIntegration(), FastApiIntegration()],
)
app = FastAPI()
  1. So I did purposefully a request that would give me a 404/500 to activate the sentry warning.

Thanks in advance.

Expected Result

Sentry 404 log sent successfully.

Actual Result

web-1 | /usr/local/lib/python3.10/site-packages/sentry_sdk/serializer.py:216: RuntimeWarning: coroutine 'request_validation_exception_handler' was never awaited
web-1 | with memo.memoize(obj) as result:
web-1 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
web-1 | ERROR: Exception in ASGI application
web-1 | Traceback (most recent call last):
web-1 | File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
web-1 | result = await app(self.scope, self.receive, self.send)
web-1 | File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 78, in call
web-1 | return await self.app(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 269, in call
web-1 | await super().call(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 268, in _sentry_patched_asgi_app
web-1 | return await middleware(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 126, in _run_asgi3
web-1 | return await self._run_app(scope, lambda: self.app(scope, receive, send))
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 176, in _run_app
web-1 | raise exc from None
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 171, in _run_app
web-1 | return await callback()
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 268, in _sentry_patched_asgi_app
web-1 | return await middleware(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 126, in _run_asgi3
web-1 | return await self._run_app(scope, lambda: self.app(scope, receive, send))
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 137, in _run_app
web-1 | raise exc from None
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 134, in _run_app
web-1 | return await callback()
web-1 | File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 124, in call
web-1 | await self.middleware_stack(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/fastapi.py", line 122, in call
web-1 | await self.app(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 461, in call
web-1 | await self.app(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 86, in _create_span_call
web-1 | await old_call(*args, **kwargs)
web-1 | File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 184, in call
web-1 | raise exc
web-1 | File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 162, in call
web-1 | await self.app(scope, receive, _send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 86, in _create_span_call
web-1 | await old_call(*args, **kwargs)
web-1 | File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 84, in call
web-1 | await self.app(scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 160, in _sentry_exceptionmiddleware_call
web-1 | await old_call(self, scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 160, in _sentry_exceptionmiddleware_call
web-1 | await old_call(self, scope, receive, send)
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 160, in _sentry_exceptionmiddleware_call
web-1 | await old_call(self, scope, receive, send)
web-1 | [Previous line repeated 1 more time]
web-1 | File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 86, in _create_span_call
web-1 | await old_call(*args, **kwargs)
web-1 | File "/usr/local/lib/python3.10/site-packages/starlette/exceptions.py", line 104, in call
web-1 | await response(scope, receive, sender)
web-1 | TypeError: 'coroutine' object is not callable

Metadata

Metadata

Assignees

Labels

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions