Skip to content

.

d47b64d
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

ref(anthropic): Skip accumulation logic for unexpected types in streamed response #5564

.
d47b64d
Select commit
Loading
Failed to load commit list.
GitHub Actions / warden: find-bugs completed Feb 27, 2026 in 2m 3s

1 issue

find-bugs: Found 1 issue (1 high)

High

NameError when Raw* types fail to import but are still referenced in isinstance checks - `sentry_sdk/integrations/anthropic.py:43-55`

When the RawMessageStartEvent, RawMessageDeltaEvent, etc. imports fail (line 54-55), message_types_have_raw_prefix is set to True, but the Raw* type names remain undefined. However, when message_types_have_raw_prefix is True, the code path in new_iterator() (lines 436-447) and new_iterator_async() (lines 500-512) evaluates isinstance(event, (RawMessageStartEvent, ...)), causing a NameError at runtime.

Also found at:

  • sentry_sdk/integrations/anthropic.py:435-447
  • sentry_sdk/integrations/anthropic.py:500-523

Duration: 2m · Tokens: 98.7k in / 5.3k out · Cost: $0.42 (+extraction: $0.01, +merge: $0.00)

Annotations

Check failure on line 55 in sentry_sdk/integrations/anthropic.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

NameError when Raw* types fail to import but are still referenced in isinstance checks

When the `RawMessageStartEvent`, `RawMessageDeltaEvent`, etc. imports fail (line 54-55), `message_types_have_raw_prefix` is set to `True`, but the `Raw*` type names remain undefined. However, when `message_types_have_raw_prefix` is `True`, the code path in `new_iterator()` (lines 436-447) and `new_iterator_async()` (lines 500-512) evaluates `isinstance(event, (RawMessageStartEvent, ...))`, causing a `NameError` at runtime.

Check failure on line 447 in sentry_sdk/integrations/anthropic.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

[ENY-2R6] NameError when Raw* types fail to import but are still referenced in isinstance checks (additional location)

When the `RawMessageStartEvent`, `RawMessageDeltaEvent`, etc. imports fail (line 54-55), `message_types_have_raw_prefix` is set to `True`, but the `Raw*` type names remain undefined. However, when `message_types_have_raw_prefix` is `True`, the code path in `new_iterator()` (lines 436-447) and `new_iterator_async()` (lines 500-512) evaluates `isinstance(event, (RawMessageStartEvent, ...))`, causing a `NameError` at runtime.

Check failure on line 523 in sentry_sdk/integrations/anthropic.py

See this annotation in the file changed.

@github-actions github-actions / warden: find-bugs

[ENY-2R6] NameError when Raw* types fail to import but are still referenced in isinstance checks (additional location)

When the `RawMessageStartEvent`, `RawMessageDeltaEvent`, etc. imports fail (line 54-55), `message_types_have_raw_prefix` is set to `True`, but the `Raw*` type names remain undefined. However, when `message_types_have_raw_prefix` is `True`, the code path in `new_iterator()` (lines 436-447) and `new_iterator_async()` (lines 500-512) evaluates `isinstance(event, (RawMessageStartEvent, ...))`, causing a `NameError` at runtime.