question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:10
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
antonpirkercommented, Jul 22, 2022

@ybinnenwegin2ip Thanks for the project to reproduce this!

So there are two issues:

  • When going to a non existent route the coroutine error is raised
  • When posting a form we end up in an infinite loop.

I have reproduced both problems but will not be able to fix them before the weekend. Will fix this beginning of next week.

2reactions
twogoodcommented, Aug 3, 2022

Any progress on this? Edit: sorry, didn’t see the PR #1532 ! Great work!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Telethon Python asyncio TypeError: 'coroutine' object is not ...
The reason is that create_client(number) returns a coroutine object, however asyncio.as_completed expects a list of futures.
Read more >
tiangolo/fastapi - Gitter
Hi, does anyone know why these errors happen - Class 'api.schemas.instructor.Instructor' is not mapped" when trying to add a user to the db?...
Read more >
[typeerror("'coroutine' object is not iterable ... - You.com
I used the GitHub search to find a similar issue and didn't find it. I searched the FastAPI documentation, with the integrated search....
Read more >
Looking for advice on functionality not liking middleware async
I'm using the Django ORM in a FastAPI app. So far, I haven't had any issue, until I tried ... TypeError: 'coroutine' object...
Read more >
'coroutine' object is not iterable] when I used sanic and aiohttp
Coding example for the question I got a error [TypeError: 'coroutine' object is not iterable] when I used sanic and aiohttp.
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