sentry-python: SQLAlchemy integration fails to parse version `2.0.5.post1`
How do you use Sentry?
Self-hosted/on-premise
Version
1.16.0
Steps to Reproduce
Call sentry_sdk.init() with SQLAlchemy integration and install SQLAlchemy==2.0.5.post1.
Expected Result
Success.
Actual Result
File "///src/.../__init__.py", line 150, in <module>
sentry_sdk.init(
File "///.tox/py/lib/python3.10/site-packages/sentry_sdk/hub.py", line 121, in _init
client = Client(*args, **kwargs) # type: ignore
File "///.tox/py/lib/python3.10/site-packages/sentry_sdk/client.py", line 117, in __init__
self._init_impl()
File "///.tox/py/lib/python3.10/site-packages/sentry_sdk/client.py", line 151, in _init_impl
self.integrations = setup_integrations(
File "///.tox/py/lib/python3.10/site-packages/sentry_sdk/integrations/__init__.py", line 124, in setup_integrations
type(integration).setup_once()
File "///.tox/py/lib/python3.10/site-packages/sentry_sdk/integrations/sqlalchemy.py", line 37, in setup_once
raise DidNotEnable(
sentry_sdk.integrations.DidNotEnable: Unparsable SQLAlchemy version: 2.0.5.post1
This is very similar to https://github.com/getsentry/sentry-python/issues/1811, which was fixed in #1812 but that doesn’t handle all the possible PEP440 variations, [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 12
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Downgrade sqlalchemy as Sentry fails to parse its version https://github.com/getsentry/sentry-python/issues/1941 — committed to flathub-infra/website by barthalion a year ago
I mean unless you’ve fixed it, this will break the moment SQLAlchemy (or probably any other dependency like that?) releases version with a tag?
You can upgrade to 2.0.6 and remove the pin
because I didn’t know about that! thanks ^^
The real question is why you don’t set up Sentry in your tests. If you don’t provide a token, it will set up but not report. That’s how I found out about it.
I extremely prefer a crash over a silently disabled error reporting.
The version parsing in the other integrations is equally brittle in relation to PEP 440. It’s probably best to use the regular expression provided in the PEP and parse the
releasegroup:Alternatively
packaging.versionorparverwould work (probably not worth adding a dependency here).