Skip to content

merge master

eb1d6a7
Select commit
Loading
Failed to load commit list.
Merged

feat(anthropic): Emit AI Client Spans for synchronous messages.stream() #5565

merge master
eb1d6a7
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: find-bugs completed Mar 13, 2026 in 7m 4s

2 issues

find-bugs: Found 2 issues (1 high, 1 low)

High

Tuple unpacking mismatch causes ValueError in synchronous message iterator - `sentry_sdk/integrations/anthropic.py:423-432`

The new _wrap_synchronous_message_iterator function at line 394 unpacks only 3 values (model, usage, content_blocks) from _collect_ai_data, but that function returns a 4-tuple that includes response_id. This causes a ValueError: too many values to unpack at runtime when iterating the stream. The existing version at line 517 correctly unpacks all 4 values.

Also found at:

  • sentry_sdk/integrations/anthropic.py:484-493
  • sentry_sdk/integrations/anthropic.py:394-514

Low

Test missing assertion for GEN_AI_SYSTEM span attribute - `tests/integrations/anthropic/test_anthropic.py:421-423`

The new test_stream_messages test does not verify that SPANDATA.GEN_AI_SYSTEM is set to "anthropic". Both test_streaming_create_message (line 306) and test_streaming_create_message_async (line 540) include this assertion, indicating this is an oversight. If the implementation breaks setting this attribute, the test won't catch it.

Also found at:

  • tests/integrations/anthropic/test_anthropic.py:439

Duration: 6m 59s · Tokens: 2.4M in / 23.4k out · Cost: $3.31 (+extraction: $0.00, +merge: $0.00, +fix_gate: $0.00)

Annotations

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

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

Tuple unpacking mismatch causes ValueError in synchronous message iterator

The new `_wrap_synchronous_message_iterator` function at line 394 unpacks only 3 values (`model`, `usage`, `content_blocks`) from `_collect_ai_data`, but that function returns a 4-tuple that includes `response_id`. This causes a `ValueError: too many values to unpack` at runtime when iterating the stream. The existing version at line 517 correctly unpacks all 4 values.

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

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

[UKG-6Y9] Tuple unpacking mismatch causes ValueError in synchronous message iterator (additional location)

The new `_wrap_synchronous_message_iterator` function at line 394 unpacks only 3 values (`model`, `usage`, `content_blocks`) from `_collect_ai_data`, but that function returns a 4-tuple that includes `response_id`. This causes a `ValueError: too many values to unpack` at runtime when iterating the stream. The existing version at line 517 correctly unpacks all 4 values.

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

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: find-bugs

[UKG-6Y9] Tuple unpacking mismatch causes ValueError in synchronous message iterator (additional location)

The new `_wrap_synchronous_message_iterator` function at line 394 unpacks only 3 values (`model`, `usage`, `content_blocks`) from `_collect_ai_data`, but that function returns a 4-tuple that includes `response_id`. This causes a `ValueError: too many values to unpack` at runtime when iterating the stream. The existing version at line 517 correctly unpacks all 4 values.