Skip to content

fix: support sentry-sdk 3 in SentryClient - #1417

Open
itzzdev09 wants to merge 2 commits into
Aiven-Open:mainfrom
itzzdev09:support-sentry-sdk-3
Open

itzzdev09 wants to merge 2 commits into
Aiven-Open:mainfrom
itzzdev09:support-sentry-sdk-3

Conversation

@itzzdev09

Copy link
Copy Markdown

About this change - What it does

SentryClient uses sentry_sdk.Hub, which sentry-sdk 3.0.0 (released this month) removed. The sentry-sdk extra only sets a lower bound, so with a current release both unexpected_exception() and close() raise:

AttributeError: module 'sentry_sdk' has no attribute 'Hub'

References: none

Why this way

sentry_sdk.capture_exception() takes the same arguments as the Hub method and exists in 1.x, 2.x and 3.x. For close(), sentry_sdk.get_client() exists from 2.0, with a fallback to Hub.current.client on 1.x, so the >=1.6.0 bound can stay.

Added tests/unit/test_sentry_client.py, which captures an event and checks its tags. I ran it on its own on python:3.12 (not the whole unit suite):

sentry-sdk before after
1.45.1 passes passes
2.77.0 passes (deprecation warnings) passes
3.0.1 AttributeError passes

Change type

  • Breaking change (breaking): describe what users must change
  • New feature or config option (enhancement)
  • Bug fix (bug)
  • Docs, tests or maintenance (doc, test, tech debt)

@itzzdev09
itzzdev09 requested a review from a team as a code owner November 28, 2026 07:13
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