Skip to content

fix: Allow to correctly compare parsed versions - #7184

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

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

Conversation

@sentrivana

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.

In this PR, we pad out any one- or two-tuples with zeroes until we have a three-tuple.

@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

112274 passed | ❌ 3 failed | ⏭️ 6751 skipped | Total: 119028 | Pass Rate: 94.33% | Execution Time: 404m 45s

📊 Comparison with Base Branch

Metric Change
Total Tests 📉 -194
Passed Tests 📉 -189
Failed Tests 📈 +3
Skipped Tests 📉 -8

➕ New Tests (3)

View new tests
  • test_span_streaming_quart_auth_user_id[42-True]
    • File: tests.integrations.quart.test_quart
    • Status: ❌ Failing
  • test_span_streaming_quart_auth_user_id[42-True]
    • File: tests.integrations.quart.test_quart
    • Status: ❌ Failing
  • test_continuous_profiler_auto_start_and_stop_sampled[experiment-gevent]
    • File: tests.profiler.test_continuous_profiler
    • Status: ❌ Failing

❌ Failed Tests

test_span_streaming_quart_auth_user_id[42-True]

File: tests.integrations.quart.test_quart
Suite: py3.13-quart-v0.21.0
Error: KeyError: 'user.id'

Stack Trace
tests/integrations/quart/test_quart.py:1117: in test_span_streaming_quart_auth_user_id
    assert segment["attributes"]["user.id"] == user_id
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   KeyError: 'user.id'

test_span_streaming_quart_auth_user_id[42-True]

File: tests.integrations.quart.test_quart
Suite: py3.14-quart-v0.21.0
Error: KeyError: 'user.id'

Stack Trace
tests/integrations/quart/test_quart.py:1117: in test_span_streaming_quart_auth_user_id
    assert segment["attributes"]["user.id"] == user_id
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   KeyError: 'user.id'

test_continuous_profiler_auto_start_and_stop_sampled[experiment-gevent]

File: tests.profiler.test_continuous_profiler
Suite: py3.6-gevent
Error: AssertionError: profiler should not be running assert '648ac74a982143a9bbce030dc5cc02ae' is None + where '648ac74a982143a9bbce030dc5cc02ae' = get_profiler_id()

Stack Trace
tests/profiler/test_continuous_profiler.py:812: in test_continuous_profiler_auto_start_and_stop_sampled
    assert get_profiler_id() is None, "profiler should not be running"
E   AssertionError: profiler should not be running
E   assert '648ac74a982143a9bbce030dc5cc02ae' is None
E    +  where '648ac74a982143a9bbce030dc5cc02ae' = get_profiler_id()

✅ Patch coverage is 100.00%. Project has 2482 uncovered lines.
✅ Project coverage is 90.22%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/utils.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    90.22%    90.22%        —%
==========================================
  Files          193       193         —
  Lines        25361     25366        +5
  Branches      9302      9308        +6
==========================================
+ Hits         22880     22884        +4
- Misses        2481      2482        +1
- Partials      1436      1431        -5

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

@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 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit cf58a84. Configure here.

Comment thread sentry_sdk/utils.py
if len(release_tuple) == 1:
release_tuple = (release_tuple[0], 0, 0)
elif len(release_tuple) == 2:
release_tuple = (release_tuple[0], release_tuple[1], 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Padding breaks two-part version equality

Low Severity

Padding parse_version so it always returns a three-tuple makes two-part results no longer equal two-part literals. The Sanic 21.9 workaround uses SanicIntegration.version == (21, 9) and will not run for a two-part 21.9 string, so the exception-path context exit is skipped.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit cf58a84. Configure here.

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.

1 participant