Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sentry/testutils/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert False, "gen_ai.conversation.id is deprecated. Use the newer indexed on instead."
assert False, "gen_ai.conversation.id is deprecated. Use the newer indexed one 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", ""),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test helper mismatches production path

Medium Severity

span_to_trace_item seeds TraceItem.conversation_id from a fabricated ai_conversation_id field and asserts when only gen_ai.conversation.id is present. Production convert_span_to_item still derives the column from that attribute and keeps it, so this rejects valid production-shaped test data and mislabels the attribute as deprecated.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e7ce3a1. Configure here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it the proper name for the attribute?

@pbhandari pbhandari Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was gonna raise this once I got everything else working. On the protobuf side ai_conversation_id doesn't exist, but conversation_id does (Protobuf Definition) (and that's what the tests rely on).

timestamp=timestamp,
trace_id=span["trace_id"],
item_id=hex_to_item_id(span["span_id"]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading