Skip to content

Commit 0aebdec

Browse files
committed
raise when only empty tag found
1 parent e195250 commit 0aebdec

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/sentry/tagstore/snuba/backend.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def __get_tag_key_and_top_values(
173173
**kwargs,
174174
):
175175
tag = self.format_string.format(key)
176-
filters = {"project_id": get_project_list(project_id), self.key_column: [key]}
176+
filters = {"project_id": get_project_list(project_id)}
177177
if environment_id:
178178
filters["environment"] = [environment_id]
179179
conditions = kwargs.get("conditions", [])
@@ -202,8 +202,15 @@ def __get_tag_key_and_top_values(
202202
tenant_ids=tenant_ids,
203203
)
204204

205-
if raise_on_empty and (not result or totals.get("count", 0) == 0):
206-
raise TagKeyNotFound if group is None else GroupTagKeyNotFound
205+
if raise_on_empty:
206+
if not result or totals.get("count", 0) == 0:
207+
raise TagKeyNotFound if group is None else GroupTagKeyNotFound
208+
209+
# Treat keys that only have empty-string values as "not found" for the
210+
# get_tag_key/get_group_tag_key family of calls.
211+
has_non_empty_value = any(value != "" for value in result.keys())
212+
if not has_non_empty_value:
213+
raise TagKeyNotFound if group is None else GroupTagKeyNotFound
207214
else:
208215
if group is None:
209216
return _make_result(

0 commit comments

Comments
 (0)