Skip to content

wrap finally in capture internal exceptions

0da2362
Select commit
Loading
Failed to load commit list.
Merged

fix(anthropic): Close span on GeneratorExit #5643

wrap finally in capture internal exceptions
0da2362
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: code-review completed Mar 13, 2026 in 49s

1 issue

code-review: Found 1 issue (1 low)

Low

Missing test coverage for GeneratorExit scenario - `sentry_sdk/integrations/anthropic.py:374-421`

The PR adds a try/finally block to ensure spans are closed when generators are not fully consumed (e.g., via GeneratorExit). However, the existing test file doesn't include tests that verify this behavior - all streaming tests iterate the entire stream with for _ in message: pass. Without tests covering early termination, the fix may regress undetected.


Duration: 48.4s · Tokens: 231.8k in / 1.7k out · Cost: $0.36