feat: Send GenAI spans as V2 envelope items #6079
3 issues
find-bugs: Found 3 issues (1 high, 1 medium, 1 low)
High
GenAI span serialization uses raw event instead of prepared event, causing missing user/release/environment data - `sentry_sdk/client.py:155-157`
On line 1124, _serialized_v1_span_to_serialized_v2_span(span, event) passes the raw event parameter instead of event_opt (the prepared event). The function expects the enriched event which contains user info, release, environment, SDK metadata, and trace context that are populated by _prepare_event() → scope.apply_to_event(). This causes all V2 span attributes like user.id, user.name, user.email, sentry.release, sentry.environment, sentry.segment.name, sentry.segment.id, sentry.sdk.name, and sentry.sdk.version to be missing or incorrect in the serialized GenAI spans.
Also found at:
sentry_sdk/client.py:1124
Medium
Test uses invalid field name 'attributes' instead of 'data' for inline_data - `tests/integrations/google_genai/test_google_genai.py:2153`
The test change replaces the correct field name data with an invalid field name attributes inside the inline_data dict. The Google GenAI SDK and all production code in this repository (specifically transform_google_content_part in sentry_sdk/ai/utils.py line 286) expect inline_data.get("data", ""). With attributes instead of data, the extraction will return an empty string for the content field, making this test ineffective at validating real-world usage.
Low
Sorting key uses 'name' twice instead of 'name' and 'description' - `tests/integrations/google_genai/test_google_genai.py:330`
The sorting lambda was incorrectly changed from (t.get("name", ""), t.get("description", "")) to (t.get("name", ""), t.get("name", "")). The comment on line 328 explicitly states the intent is to 'sort by name and description', but the implementation now sorts by name twice, making the secondary sort key redundant. This could lead to non-deterministic ordering if tools have the same name but different descriptions.
Duration: 24m 59s · Tokens: 7.5M in / 80.0k out · Cost: $11.04 (+extraction: $0.01, +merge: $0.00, +fix_gate: $0.01)
Annotations
Check failure on line 157 in sentry_sdk/client.py
sentry-warden / warden: find-bugs
GenAI span serialization uses raw event instead of prepared event, causing missing user/release/environment data
On line 1124, `_serialized_v1_span_to_serialized_v2_span(span, event)` passes the raw `event` parameter instead of `event_opt` (the prepared event). The function expects the enriched event which contains user info, release, environment, SDK metadata, and trace context that are populated by `_prepare_event()` → `scope.apply_to_event()`. This causes all V2 span attributes like `user.id`, `user.name`, `user.email`, `sentry.release`, `sentry.environment`, `sentry.segment.name`, `sentry.segment.id`, `sentry.sdk.name`, and `sentry.sdk.version` to be missing or incorrect in the serialized GenAI spans.
Check failure on line 1124 in sentry_sdk/client.py
sentry-warden / warden: find-bugs
[DGJ-UTQ] GenAI span serialization uses raw event instead of prepared event, causing missing user/release/environment data (additional location)
On line 1124, `_serialized_v1_span_to_serialized_v2_span(span, event)` passes the raw `event` parameter instead of `event_opt` (the prepared event). The function expects the enriched event which contains user info, release, environment, SDK metadata, and trace context that are populated by `_prepare_event()` → `scope.apply_to_event()`. This causes all V2 span attributes like `user.id`, `user.name`, `user.email`, `sentry.release`, `sentry.environment`, `sentry.segment.name`, `sentry.segment.id`, `sentry.sdk.name`, and `sentry.sdk.version` to be missing or incorrect in the serialized GenAI spans.
Check warning on line 2153 in tests/integrations/google_genai/test_google_genai.py
sentry-warden / warden: find-bugs
Test uses invalid field name 'attributes' instead of 'data' for inline_data
The test change replaces the correct field name `data` with an invalid field name `attributes` inside the `inline_data` dict. The Google GenAI SDK and all production code in this repository (specifically `transform_google_content_part` in sentry_sdk/ai/utils.py line 286) expect `inline_data.get("data", "")`. With `attributes` instead of `data`, the extraction will return an empty string for the content field, making this test ineffective at validating real-world usage.