Skip to content

keep comment

f36dd5d
Select commit
Loading
Failed to load commit list.
Merged

fix(anthropic): Close span on GeneratorExit #5643

keep comment
f36dd5d
Select commit
Loading
Failed to load commit list.
@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

See this annotation in the file changed.

@sentry-warden 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.