fix(anthropic): Close span on GeneratorExit
#5643
+96
−97
Merged
@sentry/warden / warden: code-review
completed
Mar 13, 2026 in 51s
1 issue
code-review: Found 1 issue (1 medium)
Medium
Missing test coverage for GeneratorExit handling - `sentry_sdk/integrations/anthropic.py:374-420`
The PR adds try/finally blocks to close spans when generators are suspended via GeneratorExit, but no tests verify this behavior. Without tests, there's no validation that spans are correctly closed with partial data when a consumer abandons the iterator early. Test coverage should verify the span is closed and contains expected partial data.
Duration: 50.5s · Tokens: 130.5k in / 1.8k out · Cost: $0.17
Annotations
Check warning on line 420 in sentry_sdk/integrations/anthropic.py
sentry-warden / warden: code-review
Missing test coverage for GeneratorExit handling
The PR adds `try/finally` blocks to close spans when generators are suspended via `GeneratorExit`, but no tests verify this behavior. Without tests, there's no validation that spans are correctly closed with partial data when a consumer abandons the iterator early. Test coverage should verify the span is closed and contains expected partial data.
Loading