feat(cohere): upgrade integration from ai to gen_ai #6823
test-integrations-network.yml
on: pull_request
Matrix: Network
All Network tests passed
3s
Annotations
24 errors and 3 warnings
|
Network (3.6, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.6, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.7, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.7, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.11, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.11, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.12, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.12, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.13, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.13, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.14t, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.9, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.14t, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.9, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.10, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.10, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.14, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.14, ubuntu-22.04)
The operation was canceled.
|
|
Network (3.8, ubuntu-22.04)
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Network (3.8, ubuntu-22.04)
The operation was canceled.
|
|
All Network tests passed
Process completed with exit code 1.
|
|
Test Network
Canceling since a higher priority waiting request for Test Network-shellmayr/feat/upgrade-cohere-ai-integration-from-ai-to-genai exists
|
|
Streaming errors are silently swallowed in _iter_stream_events:
sentry_sdk/integrations/cohere/v1.py#L105
The `capture_internal_exceptions()` context manager wraps the entire for-loop including `yield x` on lines 105-117. Since `capture_internal_exceptions()` returns `True` from `__exit__`, any exception raised during iteration of `old_iterator` (e.g., network errors, API errors from Cohere) will be silently swallowed instead of propagating to the caller. Other SDK integrations (OpenAI, Anthropic) correctly place `capture_internal_exceptions()` only around internal SDK logic, keeping the iterator/yield outside to allow proper error propagation.
|
|
[WP8-BBT] Streaming errors are silently swallowed in _iter_stream_events (additional location):
sentry_sdk/integrations/cohere/v2.py#L99
The `capture_internal_exceptions()` context manager wraps the entire for-loop including `yield x` on lines 105-117. Since `capture_internal_exceptions()` returns `True` from `__exit__`, any exception raised during iteration of `old_iterator` (e.g., network errors, API errors from Cohere) will be silently swallowed instead of propagating to the caller. Other SDK integrations (OpenAI, Anthropic) correctly place `capture_internal_exceptions()` only around internal SDK logic, keeping the iterator/yield outside to allow proper error propagation.
|
|
get_first_from_sources incorrectly skips valid falsy values like 0:
sentry_sdk/ai/utils.py#L744
The function `get_first_from_sources` has a logic bug: `if not value: continue` on line 744 skips all falsy values including `0`, which is a legitimate token count. When used in `set_response_span_data` to extract `input_tokens`, `output_tokens`, or `total_tokens`, this causes valid zero counts from the Cohere API to be lost. The redundant condition `if not require_truthy or value` on lines 746-747 also indicates confused intent since we can only reach it when `value` is already truthy.
|
|
Stream iterator swallows exceptions under capture_internal_exceptions:
sentry_sdk/integrations/cohere/v2.py#L99
The `_iter_v2_stream_events` function wraps the entire iteration loop in `capture_internal_exceptions()`. If an exception occurs during iteration (e.g., network error, API error), it will be silently caught and suppressed rather than propagating to the caller. This differs from v1's implementation which properly propagates iteration exceptions. Users won't see streaming errors and may believe operations succeeded when they failed.
|
|
get_first_from_sources always skips falsy values regardless of require_truthy flag:
sentry_sdk/ai/utils.py#L740
The `get_first_from_sources` function has redundant logic that makes the `require_truthy` parameter ineffective. Line 744 (`if not value: continue`) unconditionally skips all falsy values (including `0`, `""`, `[]`). The subsequent check on line 746-747 (`if not require_truthy or value`) is then always True since we only reach it when `value` is truthy. This means `require_truthy=False` does not allow returning falsy-but-valid values like `0` (e.g., for token counts), which could cause missing span data when a legitimate API response contains zero values.
|