Skip to content

Commit 55473f9

Browse files
authored
fix(assisted-query): match return format for field values rpc (#103951)
Remove "values" wrapping field values results to match Seer's expectations. Fixes empty results for get_field_values in query builder
1 parent 07b3483 commit 55473f9

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/sentry/seer/assisted_query/traces_tools.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,14 @@ def get_attribute_values_with_substring(
8484
item_type: Type of trace item (default: "spans")
8585
8686
Returns:
87-
Dictionary with values:
87+
Dictionary with field names as keys and lists of values:
8888
{
89-
"values": {
90-
"span.status": ["ok", "error", ...],
91-
"transaction": ["checkout", ...]
92-
}
89+
"span.status": ["ok", "error", ...],
90+
"transaction": ["checkout", ...]
9391
}
9492
"""
9593
if not fields_with_substrings:
96-
return {"values": {}}
94+
return {}
9795

9896
organization = Organization.objects.get(id=org_id)
9997
api_key = ApiKey(organization_id=org_id, scope_list=API_KEY_SCOPES)
@@ -127,6 +125,4 @@ def get_attribute_values_with_substring(
127125
values.setdefault(field, set()).update(field_values_list[:limit])
128126

129127
# Convert sets to sorted lists for JSON serialization
130-
return {
131-
"values": {field: sorted(field_values)[:limit] for field, field_values in values.items()}
132-
}
128+
return {field: sorted(field_values)[:limit] for field, field_values in values.items()}

tests/snuba/api/endpoints/test_seer_attributes.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ def test_get_attribute_values_with_substring(self) -> None:
9090
)
9191

9292
assert result == {
93-
"values": {
94-
"transaction": ["bar", "baz"],
95-
}
93+
"transaction": ["bar", "baz"],
9694
}
9795

9896
def test_get_attributes_and_values(self) -> None:
@@ -165,7 +163,7 @@ def test_get_attribute_values_with_substring_empty_field_list(self) -> None:
165163
fields_with_substrings=[],
166164
)
167165

168-
expected: dict = {"values": {}}
166+
expected: dict = {}
169167
assert result == expected
170168

171169
def test_get_spans_basic(self) -> None:

0 commit comments

Comments
 (0)