Skip to content

.

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

ref(anthropic): Factor out streamed result handling #5563

.
db5dbb9
Select commit
Loading
Failed to load commit list.
GitHub Actions / warden completed Feb 27, 2026 in 2m 14s

2 issues

Medium

Streaming response handling no longer protected by capture_internal_exceptions - `sentry_sdk/integrations/anthropic.py:513-516`

The streaming path now checks kwargs.get("stream", False) and calls _patch_streaming_response_iterator before entering the capture_internal_exceptions() block. Previously, the streaming detection (hasattr(result, "_iterator")) was inside the exception handling block. If stream=True is passed but the result unexpectedly lacks _iterator (e.g., API behavior change, error responses), an AttributeError will propagate instead of being gracefully handled, potentially breaking the instrumented code path.

Unprotected _iterator access can crash user applications when stream=True response lacks _iterator attribute - `sentry_sdk/integrations/anthropic.py:514-516`

The refactored code accesses result._iterator directly (lines 403, 481) without verifying the attribute exists, and the call to _patch_streaming_response_iterator (line 515) is not wrapped in capture_internal_exceptions(). Previously, the streaming path was inside capture_internal_exceptions() with hasattr(result, "_iterator") check. If stream=True is passed but the response object doesn't have _iterator (e.g., API version mismatch or unexpected response type), an unhandled AttributeError will propagate to the user's application instead of being gracefully logged.

4 skills analyzed
Skill Findings Duration Cost
code-review 1 2m 6s $0.58
find-bugs 1 1m 58s $0.59
skill-scanner 0 38.2s $0.13
security-review 0 34.7s $0.17

Duration: 5m 17s · Tokens: 1.2M in / 11.8k out · Cost: $1.49 (+extraction: $0.01, +dedup: $0.00)