Skip to content

Sentry-SDK 1.33 fails to import with "parse_version` is undefined with greenlet installed #2473

Closed

Description

@potiuk

How do you use Sentry?

Sentry Saas (sentry.io)

Version

1.33.0

Steps to Reproduce

  1. Install sentry-sdk 1.32 and greenlet:
root@99404168d77f:/opt/airflow# pip freeze | grep -E "greenlet|sentry-sdk"
greenlet==3.0.1
sentry-sdk==1.32.0
root@99404168d77f:/opt/airflow# 
  1. Import sentry_sdk

root@99404168d77f:/opt/airflow# python
Python 3.8.18 (default, Oct 11 2023, 23:57:43)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.

import sentry_sdk

Works fine

  1. Upgrade to sentry_sdk 1.33.0
root@99404168d77f:/opt/airflow# pip install --upgrade sentry-sdk==1.33.0
Collecting sentry-sdk==1.33.0
  Downloading sentry_sdk-1.33.0-py2.py3-none-any.whl.metadata (9.6 kB)
Requirement already satisfied: certifi in /usr/local/lib/python3.8/site-packages (from sentry-sdk==1.33.0) (2023.7.22)
Requirement already satisfied: urllib3>=1.26.11 in /usr/local/lib/python3.8/site-packages (from sentry-sdk==1.33.0) (1.26.18)
Downloading sentry_sdk-1.33.0-py2.py3-none-any.whl (243 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 243.2/243.2 kB 2.8 MB/s eta 0:00:00
Installing collected packages: sentry-sdk
  Attempting uninstall: sentry-sdk
    Found existing installation: sentry-sdk 1.32.0
    Uninstalling sentry-sdk-1.32.0:
      Successfully uninstalled sentry-sdk-1.32.0
Successfully installed sentry-sdk-1.33.0
root@99404168d77f:/opt/airflow# pip freeze | grep -E "greenlet|sentry-sdk"
greenlet==3.0.1
sentry-sdk==1.33.0
root@99404168d77f:/opt/airflow# 
  1. Import sentry_sdk:
root@99404168d77f:/opt/airflow# python
Python 3.8.18 (default, Oct 11 2023, 23:57:43) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sentry_sdk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/__init__.py", line 1, in <module>
    from sentry_sdk.hub import Hub, init
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/hub.py", line 8, in <module>
    from sentry_sdk.scope import Scope
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/scope.py", line 7, in <module>
    from sentry_sdk.attachments import Attachment
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/attachments.py", line 5, in <module>
    from sentry_sdk.envelope import Item, PayloadRef
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/envelope.py", line 7, in <module>
    from sentry_sdk.session import Session
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/session.py", line 5, in <module>
    from sentry_sdk.utils import format_timestamp
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1240, in <module>
    HAS_REAL_CONTEXTVARS, ContextVar = _get_contextvars()
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1210, in _get_contextvars
    if not _is_contextvars_broken():
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1165, in _is_contextvars_broken
    greenlet_version = parse_version(greenlet.__version__)
NameError: name 'parse_version' is not defined
>>> 

Expected Result

The import should succeed.

Actual Result

The import fails with exception:

root@99404168d77f:/opt/airflow# python
Python 3.8.18 (default, Oct 11 2023, 23:57:43) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sentry_sdk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/__init__.py", line 1, in <module>
    from sentry_sdk.hub import Hub, init
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/hub.py", line 8, in <module>
    from sentry_sdk.scope import Scope
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/scope.py", line 7, in <module>
    from sentry_sdk.attachments import Attachment
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/attachments.py", line 5, in <module>
    from sentry_sdk.envelope import Item, PayloadRef
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/envelope.py", line 7, in <module>
    from sentry_sdk.session import Session
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/session.py", line 5, in <module>
    from sentry_sdk.utils import format_timestamp
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1240, in <module>
    HAS_REAL_CONTEXTVARS, ContextVar = _get_contextvars()
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1210, in _get_contextvars
    if not _is_contextvars_broken():
  File "/usr/local/lib/python3.8/site-packages/sentry_sdk/utils.py", line 1165, in _is_contextvars_broken
    greenlet_version = parse_version(greenlet.__version__)
NameError: name 'parse_version' is not defined
>>> 

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Oct 31, 2023
  2. potiuk commented on Oct 31, 2023

    @potiuk
    Author

    Very likely caused by #2464

  3. antonpirker commented on Oct 31, 2023

    @antonpirker
    Contributor

    Thanks @potiuk !
    I will fix this.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Oct 31, 2023
  5. self-assigned this
    on Oct 31, 2023
  6. antonpirker commented on Oct 31, 2023

    @antonpirker
    Contributor

    @potiuk I published a patch for this, please give it a try: https://github.com/getsentry/sentry-python/releases/tag/1.33.1

  7. potiuk commented on Oct 31, 2023

    @potiuk
    Author

    Confirmed it works!

  8. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Oct 31, 2023
  9. 7 remaining items

  10. potiuk commented on Oct 31, 2023

    @potiuk
    Author

    Fantastic! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions