ref(anthropic): Skip accumulation logic for unexpected types in streamed response #5564
1 issue
code-review: Found 1 issue (1 high)
High
Import logic will cause ImportError on newer anthropic SDK versions - `sentry_sdk/integrations/anthropic.py:57-64`
Lines 57-64 unconditionally import non-Raw types (MessageStartEvent, etc.) after attempting to import Raw types. According to the referenced anthropic SDK commit, newer versions of the SDK renamed these types to have the "Raw" prefix. If the Raw* imports succeed (lines 46-53), the non-Raw imports (lines 57-64) will fail with ImportError since those types no longer exist in newer SDK versions. This will cause the Sentry SDK to fail initialization with 'DidNotEnable: Anthropic not installed'.
Also found at:
sentry_sdk/integrations/anthropic.py:435-458sentry_sdk/integrations/anthropic.py:500-523
Duration: 2m 4s · Tokens: 116.8k in / 5.4k out · Cost: $0.44 (+extraction: $0.02, +merge: $0.00)
Annotations
Check failure on line 64 in sentry_sdk/integrations/anthropic.py
github-actions / warden: code-review
Import logic will cause ImportError on newer anthropic SDK versions
Lines 57-64 unconditionally import non-Raw types (MessageStartEvent, etc.) after attempting to import Raw types. According to the referenced anthropic SDK commit, newer versions of the SDK renamed these types to have the "Raw" prefix. If the Raw* imports succeed (lines 46-53), the non-Raw imports (lines 57-64) will fail with ImportError since those types no longer exist in newer SDK versions. This will cause the Sentry SDK to fail initialization with 'DidNotEnable: Anthropic not installed'.
Check failure on line 458 in sentry_sdk/integrations/anthropic.py
github-actions / warden: code-review
[VDT-8BN] Import logic will cause ImportError on newer anthropic SDK versions (additional location)
Lines 57-64 unconditionally import non-Raw types (MessageStartEvent, etc.) after attempting to import Raw types. According to the referenced anthropic SDK commit, newer versions of the SDK renamed these types to have the "Raw" prefix. If the Raw* imports succeed (lines 46-53), the non-Raw imports (lines 57-64) will fail with ImportError since those types no longer exist in newer SDK versions. This will cause the Sentry SDK to fail initialization with 'DidNotEnable: Anthropic not installed'.
Check failure on line 523 in sentry_sdk/integrations/anthropic.py
github-actions / warden: code-review
[VDT-8BN] Import logic will cause ImportError on newer anthropic SDK versions (additional location)
Lines 57-64 unconditionally import non-Raw types (MessageStartEvent, etc.) after attempting to import Raw types. According to the referenced anthropic SDK commit, newer versions of the SDK renamed these types to have the "Raw" prefix. If the Raw* imports succeed (lines 46-53), the non-Raw imports (lines 57-64) will fail with ImportError since those types no longer exist in newer SDK versions. This will cause the Sentry SDK to fail initialization with 'DidNotEnable: Anthropic not installed'.