Skip to content

Commit 2b2b121

Browse files
committed
fix(search): Dont create an empty "query" param
This ensures we're not passing an invalid 'query=[]' token to upstream users, which would commonly treat this as 'find something with a blank string' and exclude searches that might have been operating on NULL columns.
1 parent f26589f commit 2b2b121

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/sentry/search/utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ def tokenize_query(query):
331331
break
332332
query_params[state].append(token)
333333

334-
result["query"] = map(format_query, query_params["query"])
334+
if "query" in query_params:
335+
result["query"] = map(format_query, query_params["query"])
335336
for tag in query_params["tags"]:
336337
key, value = format_tag(tag)
337338
result[key].append(value)

tests/sentry/search/test_utils.py

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
get_latest_release,
2222
get_numeric_field_value,
2323
convert_user_tag_to_query,
24+
tokenize_query,
2425
InvalidQuery,
2526
)
2627

@@ -47,6 +48,10 @@ def test_get_numeric_field_value():
4748
}
4849

4950

51+
def test_tokenize_query_only_keyed_fields():
52+
assert tokenize_query("foo:bar") == {"foo": ["bar"]}
53+
54+
5055
def test_get_numeric_field_value_invalid():
5156
with pytest.raises(InvalidQuery):
5257
get_numeric_field_value("foo", ">=1k")

0 commit comments

Comments
 (0)