File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/sentry/tagstore/snuba Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments