Sitelet https://github.com/getsentry/sentry-python/pull/7184
Skip to content

fix: Allow to correctly compare parsed versions - #7184

Open
sentrivana wants to merge 6 commits into
masterfrom
ivana/pad-out-parse-version
Open

fix: Allow to correctly compare parsed versions#7184
sentrivana wants to merge 6 commits into
masterfrom
ivana/pad-out-parse-version

Conversation

@sentrivana

@sentrivana sentrivana commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Originally raised by a bot here: the parse_version function parses version strings as is (e.g. 3.1 becomes (3, 1)). We use these parsed version tuples in integrations to compare the installed version against the minimum (defined in integrations/__init__.py). The minimum versions are often three-part, e.g. (3, 1, 0).

This means that we can mistakenly consider a valid version to be below the minimum, because in pure tuple terms, (3, 1) < (3, 1, 0) is true.

This can also happen in reverse (package version has three parts, while our min version boundary has two).

In this PR, we make the internal version comparison work as expected regardless of mismatches in the length of the version strings/tuples.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

113478 passed | ⏭️ 6769 skipped | Total: 120247 | Pass Rate: 94.37% | Execution Time: 399m 45s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -4124
Passed Tests 📉 -4160
Failed Tests 📉 -1
Skipped Tests 📈 +37

➖ Removed Tests (1)

View removed tests
  • test_cache_spans_item_size[True]
    • File: tests.integrations.django.test_cache_module

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2491 uncovered lines.
❌ Project coverage is 90.2%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/init.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    90.21%    90.20%    -0.01%
==========================================
  Files          193       193         —
  Lines        25433     25429        -4
  Branches      9346      9342        -4
==========================================
+ Hits         22945     22938        -7
- Misses        2488      2491        +3
- Partials      1436      1439        +3

Generated by Codecov Action

@sentrivana
sentrivana marked this pull request as ready for review August 13, 2026 08:46
@sentrivana
sentrivana requested a review from a team as a code owner August 13, 2026 08:46
Comment thread sentry_sdk/utils.py Outdated

@ericapisani ericapisani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment left by bugbot regarding sanic looks legit. Looks like a quick fix though so approving in order to not block because the changes LGTM otherwise

@sentrivana
sentrivana marked this pull request as draft August 24, 2026 09:20

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 882ff7a. Configure here.

Comment thread tests/test_utils.py
Comment thread tests/test_utils.py Outdated

try:
from celery import VERSION as CELERY_VERSION # type: ignore
from celery import __version__ as CELERY_VERSION # type: ignore

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERSION is celery's own namedtuple that they parse out of __version__. Use the raw version instead now -- the namedtuple won't compare natively anymore.

@sentrivana
sentrivana marked this pull request as ready for review August 24, 2026 09:40
@sentrivana
sentrivana requested a review from ericapisani August 25, 2026 08:32
@sentrivana

Copy link
Copy Markdown
Contributor Author

Re-tagging you for a review @ericapisani since I've changed this PR substantially 🙏🏻

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants