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: find-bugs completed Feb 27, 2026 in 1m 59s

1 issue

find-bugs: Found 1 issue (1 medium)

Medium

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.


Duration: 1m 58s · Tokens: 545.3k in / 4.4k out · Cost: $0.60 (+extraction: $0.00)

Annotations

Check warning on line 516 in sentry_sdk/integrations/anthropic.py

See this annotation in the file changed.

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

Unprotected _iterator access can crash user applications when stream=True response lacks _iterator attribute

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.