Skip to content

fix: gracefully handle sentry-sdk < 2.0 in telemetry - #748

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/sentry-sdk-compat
Open

fix: gracefully handle sentry-sdk < 2.0 in telemetry#748
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/sentry-sdk-compat

Conversation

@sentry

@sentry sentry Bot commented Aug 2, 2026

Copy link
Copy Markdown

This PR addresses an ImportError occurring when codecov-cli attempts to import get_current_scope from sentry_sdk.scope, which is only available in sentry-sdk versions 2.0 and above. The issue arises when the CLI is run in an environment with sentry-sdk v1.x installed, despite pyproject.toml specifying sentry-sdk==2.*.

To fix this:

  1. The call to sentry_sdk.get_current_scope().transaction in upload_sender.py is now wrapped in a try/except AttributeError block. This prevents a hard crash if get_current_scope is missing, allowing the CLI to continue execution without Sentry transaction data in such cases.
  2. A version check has been added to opentelemetry.py during Sentry SDK initialization. If sentry-sdk version is detected to be less than 2.0, a warning is logged, providing early diagnostic information about the environment mismatch.

Fixes CLI-FW

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
723 1 722 1
View the full list of 1 ❄️ flaky test(s)
api.temp.calculator.test_calculator::test_divide

Flake rate in main: 100.00% (Passed 0 times, Failed 1625 times)

Stack Traces | 0.001s run time
def
                test_divide():
                > assert Calculator.divide(1, 2) == 0.5
                E assert 1.0 == 0.5
                E + where 1.0 = <function Calculator.divide at 0x104c9eb90>(1, 2)
                E + where <function Calculator.divide at 0x104c9eb90> = Calculator.divide
                .../temp/calculator/test_calculator.py:30: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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.

0 participants