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.

TypeError: 'NoneType' object is not subscriptable

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:10
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

5reactions
antonpirkercommented, Oct 21, 2022

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)

4reactions
tonalcommented, Oct 21, 2022

Downgrade to sentry-sdk-1.9.10 work

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: 'NoneType' object is not subscriptable
NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return...
Read more >
Python Math - TypeError: 'NoneType' object is not subscriptable
The reason that lista gets set to None is because the return value of list.sort() is None ... it does not return a...
Read more >
[Solved] TypeError: 'NoneType' Object is Not Subscriptable
The error, NoneType object is not subscriptable, means that you were trying to subscript a NoneType object. This resulted in a type error....
Read more >
Python TypeError: 'NoneType' object is not subscriptable
The “TypeError: 'NoneType' object is not subscriptable” error is common if you assign the result of a built-in list method like sort() ,...
Read more >
TypeError: 'NoneType' object is not subscriptable in Python
The Python "TypeError: 'NoneType' object is not subscriptable" occurs when we try to access a None value at a specific index. To solve...
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