Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
potiuk opened this issue Oct 31, 2023 · 9 comments · Fixed by #2474
Closed
Assignees

Comments

@potiuk
Copy link

potiuk commented Oct 31, 2023

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
>>> 
@potiuk
Copy link
Author

potiuk commented Oct 31, 2023

Very likely caused by #2464

potiuk added a commit to potiuk/airflow that referenced this issue Oct 31, 2023
The sentry_sdk 1.33.0 is broken, it fails to import when greenlet is
installed. See:

getsentry/sentry-python#2473

Most likely the will quickly release new version so != should be fine.
potiuk added a commit to apache/airflow that referenced this issue Oct 31, 2023
The sentry_sdk 1.33.0 is broken, it fails to import when greenlet is
installed. See:

getsentry/sentry-python#2473

Most likely the will quickly release new version so != should be fine.
@antonpirker
Copy link
Member

Thanks @potiuk !
I will fix this.

@antonpirker
Copy link
Member

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

@potiuk
Copy link
Author

potiuk commented Oct 31, 2023

Confirmed it works!

@potiuk
Copy link
Author

potiuk commented Oct 31, 2023

Thanks for super-speedy fix :)

@potiuk
Copy link
Author

potiuk commented Oct 31, 2023

BTW. Would be great to yank 1.33.0 if you have not done it yet, that will avoid someone getting into it accidentally

@antonpirker
Copy link
Member

True. I see If I have the permissions to do this.

@antonpirker
Copy link
Member

Yanked!

@potiuk potiuk closed this as completed Oct 31, 2023
@potiuk
Copy link
Author

potiuk commented Oct 31, 2023

Fantastic! Thanks!

ephraimbuddy pushed a commit to apache/airflow that referenced this issue Oct 31, 2023
The sentry_sdk 1.33.0 is broken, it fails to import when greenlet is
installed. See:

getsentry/sentry-python#2473

Most likely the will quickly release new version so != should be fine.

(cherry picked from commit 76847f8)
ahidalgob pushed a commit to GoogleCloudPlatform/composer-airflow that referenced this issue May 15, 2024
The sentry_sdk 1.33.0 is broken, it fails to import when greenlet is
installed. See:

getsentry/sentry-python#2473

Most likely the will quickly release new version so != should be fine.

(cherry picked from commit 76847f89629d853b6afb6ca38114d71d232fb7b1)

GitOrigin-RevId: b9af4efb69570f8f76a14c7ad201cf15cfbf625c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants