From 2beeffb3572b6738faaccf3854e8286ca3a4b944 Mon Sep 17 00:00:00 2001 From: Prajjwal Bhandari Date: Fri, 24 Jul 2026 18:45:44 -0400 Subject: [PATCH] fix(ci): Update tests to seed the correct column for ai_conversations --- src/sentry/testutils/cases.py | 3 +++ .../endpoints/test_organization_ai_conversations_base.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/sentry/testutils/cases.py b/src/sentry/testutils/cases.py index cd4e0097e3d7..a9827e3d1099 100644 --- a/src/sentry/testutils/cases.py +++ b/src/sentry/testutils/cases.py @@ -3434,10 +3434,13 @@ def span_to_trace_item(span) -> TraceItem: timestamp.FromMilliseconds(span["start_timestamp_ms"]) + if "gen_ai.conversation.id" in span.get("data", {}) and "ai_conversation_id" not in span: + assert False, "gen_ai.conversation.id is deprecated. Use the newer indexed on instead." return TraceItem( organization_id=span["organization_id"], project_id=span["project_id"], item_type=TraceItemType.TRACE_ITEM_TYPE_SPAN, + conversation_id=span.get("ai_conversation_id", ""), timestamp=timestamp, trace_id=span["trace_id"], item_id=hex_to_item_id(span["span_id"]), diff --git a/tests/sentry/api/endpoints/test_organization_ai_conversations_base.py b/tests/sentry/api/endpoints/test_organization_ai_conversations_base.py index 762629309dd5..60ce585b89bb 100644 --- a/tests/sentry/api/endpoints/test_organization_ai_conversations_base.py +++ b/tests/sentry/api/endpoints/test_organization_ai_conversations_base.py @@ -49,7 +49,7 @@ def store_ai_span( """Create and store an AI span with the given attributes. Args: - conversation_id: The gen_ai.conversation.id attribute + conversation_id: The gen_ai.conversation.id(old), and ai_conversation_id(new), attribute timestamp: The span start timestamp op: The span operation (default: "gen_ai.chat") description: Span description @@ -78,7 +78,10 @@ def store_ai_span( Returns: The created span object """ - span_data = {"gen_ai.conversation.id": conversation_id} + span_data = { + # deprecated in favour of `ai_conversation_id` down below. + "gen_ai.conversation.id": conversation_id, + } if operation_type: span_data["gen_ai.operation.type"] = operation_type if tokens is not None: @@ -125,6 +128,7 @@ def store_ai_span( "description": description or "default", "sentry_tags": {"status": status, "op": op}, "data": span_data, + "ai_conversation_id": conversation_id, } if trace_id: extra_data["trace_id"] = trace_id