Skip to content

ref(anthropic): Skip accumulation logic for unexpected types in streamed response #6714

ref(anthropic): Skip accumulation logic for unexpected types in streamed response

ref(anthropic): Skip accumulation logic for unexpected types in streamed response #6714

Triggered via pull request February 27, 2026 13:06
Status Success
Total duration 9m 39s
Artifacts 2

test-integrations-tasks.yml

on: pull_request
Matrix: Tasks
All Tasks tests passed
3s
All Tasks tests passed
Fit to window
Zoom out
Zoom in

Annotations

6 errors and 28 warnings
Inverted boolean flag causes incorrect event type filtering: sentry_sdk/integrations/anthropic.py#L42
The `message_types_have_raw_prefix` flag is set incorrectly: it starts as `False` and is set to `True` only when the `RawMessage*Event` imports fail. This is backwards - if the `Raw*` types can be imported, the SDK has the raw prefix (flag should be `True`). If imports fail, it means there's no raw prefix (flag should be `False`). This causes the streaming event type filtering logic (lines 434-459, 499-524) to behave incorrectly, potentially skipping data collection for valid events or attempting to use `RawMessage*Event` types that weren't successfully imported.
[B3A-766] Inverted boolean flag causes incorrect event type filtering (additional location): sentry_sdk/integrations/anthropic.py#L434
The `message_types_have_raw_prefix` flag is set incorrectly: it starts as `False` and is set to `True` only when the `RawMessage*Event` imports fail. This is backwards - if the `Raw*` types can be imported, the SDK has the raw prefix (flag should be `True`). If imports fail, it means there's no raw prefix (flag should be `False`). This causes the streaming event type filtering logic (lines 434-459, 499-524) to behave incorrectly, potentially skipping data collection for valid events or attempting to use `RawMessage*Event` types that weren't successfully imported.
[B3A-766] Inverted boolean flag causes incorrect event type filtering (additional location): sentry_sdk/integrations/anthropic.py#L499
The `message_types_have_raw_prefix` flag is set incorrectly: it starts as `False` and is set to `True` only when the `RawMessage*Event` imports fail. This is backwards - if the `Raw*` types can be imported, the SDK has the raw prefix (flag should be `True`). If imports fail, it means there's no raw prefix (flag should be `False`). This causes the streaming event type filtering logic (lines 434-459, 499-524) to behave incorrectly, potentially skipping data collection for valid events or attempting to use `RawMessage*Event` types that weren't successfully imported.
NameError when Raw* types fail to import but are still referenced in isinstance checks: sentry_sdk/integrations/anthropic.py#L42
When the `RawMessageStartEvent` and related types fail to import (older anthropic SDK versions), `message_types_have_raw_prefix` is set to `True`. However, the streaming iterator logic then checks `message_types_have_raw_prefix and not isinstance(event, (RawMessageStartEvent, ...))`, which will cause a `NameError` because `RawMessageStartEvent` is undefined when the import failed. The boolean flag semantics are inverted - it's `True` when Raw types DON'T exist, yet the code tries to use those types in that branch.
[BPG-XWY] NameError when Raw* types fail to import but are still referenced in isinstance checks (additional location): sentry_sdk/integrations/anthropic.py#L434
When the `RawMessageStartEvent` and related types fail to import (older anthropic SDK versions), `message_types_have_raw_prefix` is set to `True`. However, the streaming iterator logic then checks `message_types_have_raw_prefix and not isinstance(event, (RawMessageStartEvent, ...))`, which will cause a `NameError` because `RawMessageStartEvent` is undefined when the import failed. The boolean flag semantics are inverted - it's `True` when Raw types DON'T exist, yet the code tries to use those types in that branch.
[BPG-XWY] NameError when Raw* types fail to import but are still referenced in isinstance checks (additional location): sentry_sdk/integrations/anthropic.py#L499
When the `RawMessageStartEvent` and related types fail to import (older anthropic SDK versions), `message_types_have_raw_prefix` is set to `True`. However, the streaming iterator logic then checks `message_types_have_raw_prefix and not isinstance(event, (RawMessageStartEvent, ...))`, which will cause a `NameError` because `RawMessageStartEvent` is undefined when the import failed. The boolean flag semantics are inverted - it's `True` when Raw types DON'T exist, yet the code tries to use those types in that branch.
Tasks (3.11, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.8, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.8, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.8, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.6, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.6, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.6, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.9, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.9, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.9, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.14t, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.14t, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.14t, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.7, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.7, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.7, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.14, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.14, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.14, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.10, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.10, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.10, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.12, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.12, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.12, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.13, ubuntu-22.04)
❌ Patch coverage check failed: 0.00% < target 80%
Tasks (3.13, ubuntu-22.04)
Failed to upload coverage artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run
Tasks (3.13, ubuntu-22.04)
Failed to upload test artifact: Failed to CreateArtifact: Received non-retryable error: Failed request: (409) Conflict: an artifact with this name already exists on the workflow run

Artifacts

Produced during runtime
Name Size Digest
codecov-coverage-results-webb-anthropic-only-raw-message-stream-events-test-tasks
105 KB
sha256:8f84592f072c217ca93c2b998afaecbe843043ee21d761e6c651fa3360e44ec0
codecov-test-results-webb-anthropic-only-raw-message-stream-events-test-tasks
232 Bytes
sha256:7160df20ce6948e0ea8c9536b1898cd19ac6db617b0d851fe23e72116b45dddd