sentry-python: TypeError: 'NoneType' object is not subscriptable
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.10.0
Steps to Reproduce
Just updated from 1.9.5 to 1.10.0 and got:
self = <starlette.responses.StreamingResponse object at 0x156348d00>, receive = <function _enable_span_for_middleware.<locals>._create_span_call.<locals>._sentry_receive at 0x158981870>
async def listen_for_disconnect(self, receive: Receive) -> None:
while True:
message = await receive()
> if message["type"] == "http.disconnect":
E TypeError: 'NoneType' object is not subscriptable
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/responses.py:234: TypeError
I integrate sentry as follows:
import sentry_sdk
from fastapi import FastAPI
from sentry_sdk.integrations.fastapi import FastApiIntegration
from sentry_sdk.integrations.starlette import StarletteIntegration
from ..config import env
app = FastAPI(openapi_url=None)
try:
sentry_sdk.init(
dsn=env.SENTRY_DSN,
traces_sample_rate=1.0,
environment=env.ENV,
integrations=[
StarletteIntegration(),
FastApiIntegration(),
],
)
except Exception:
# pass silently if the Sentry integration failed
pass
The whole list:
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_client.py:1751: in get
return await self.request(
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_client.py:1527: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/httpx.py:88: in send
rv = await real_send(self, request, **kwargs)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_client.py:1614: in send
response = await self._send_handling_auth(
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_client.py:1642: in _send_handling_auth
response = await self._send_handling_redirects(
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_client.py:1679: in _send_handling_redirects
response = await self._send_single_request(request)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_client.py:1716: in _send_single_request
response = await transport.handle_async_request(request)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/httpx/_transports/asgi.py:152: in handle_async_request
await self.app(scope, receive, send)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/fastapi/applications.py:269: in __call__
await super().__call__(scope, receive, send)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py:322: in _sentry_patched_asgi_app
return await middleware(scope, receive, send)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py:139: in _run_asgi3
return await self._run_app(scope, lambda: self.app(scope, receive, send))
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py:188: in _run_app
raise exc from None
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py:183: in _run_app
return await callback()
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/applications.py:124: in __call__
await self.middleware_stack(scope, receive, send)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py:127: in _create_span_call
await old_call(app, scope, new_receive, new_send, **kwargs)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py:184: in __call__
raise exc
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/middleware/errors.py:162: in __call__
await self.app(scope, receive, _send)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py:127: in _create_span_call
await old_call(app, scope, new_receive, new_send, **kwargs)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/middleware/base.py:69: in __call__
await response(scope, receive, send)
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/responses.py:260: in __call__
await wrap(partial(self.listen_for_disconnect, receive))
../../../../Library/Caches/pypoetry/virtualenvs/python-embeddings-service-TzypkFmU-py3.10/lib/python3.10/site-packages/starlette/responses.py:256: in wrap
await func()
_ _ _ _ _ _ _ _ _ _ _ _ _
Expected Result
Sentry SDK should work when executing tests.
Actual Result
The SDK runs smoothly when starting the fastpi server, but if fails big time when executing tests. No errors with 1.9.5 though
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 10
- Comments: 20 (8 by maintainers)
Thanks for all the input! ❤️
We have a bugfix on the way, but I guess it will not be released today, but on Monday. (Because I want to add more tests and catch more edge cases so that we future proof the code)
Downgrade to sentry-sdk-1.9.10 work
A bug fix release has just been deployed: https://github.com/getsentry/sentry-python/releases/tag/1.10.1
Please test it with the new version and tell me if it is working!
1.10.1 Work for my. Thanks!
Yeah, it seems to be working. Thanks!
Same issue here, downgrade to 1.9.10 to get it work.
Same issue here. 🙈 Downgrading worked as a quick fix.