Skip to content
Merged
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
16 changes: 13 additions & 3 deletions src/sentry/search/events/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,19 @@ def convert_search_filter_to_snuba_query(
# together. Otherwise just return the raw condition, so that it can be
# used correctly in aggregates.
if is_null_condition:
return [is_null_condition, condition]
else:
return condition
return [is_null_condition, *_flatten_conditions(condition)]
return condition


def _flatten_conditions(cond: list[Any]) -> list[Any]:
"""
Flatten nested legacy conditions into a flat list. A legacy condition is
[lhs, op_string, rhs]. Wildcard processing can create nested lists that
snuba_sdk.legacy.parse_condition cannot handle.
"""
if len(cond) == 3 and isinstance(cond[1], str):
return [cond]
return [c for item in cond if isinstance(item, list) for c in _flatten_conditions(item)]


def format_search_filter(term, params):
Expand Down
17 changes: 17 additions & 0 deletions tests/sentry/issues/endpoints/test_group_event_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,23 @@ def test_query_title(self) -> None:
assert response.data["previousEventID"] is None
assert response.data["nextEventID"] is None

def test_query_title_not_in_with_wildcards(self) -> None:
event_e = self.store_event(
data={
"event_id": "e" * 32,
"environment": "staging",
"timestamp": before_now(minutes=1).isoformat(),
"fingerprint": ["group-title-wildcard"],
"message": "some other title",
},
project_id=self.project_1.id,
)

url = f"/api/0/issues/{event_e.group.id}/events/recommended/"
response = self.client.get(url, {"query": '!title:["*value1*", "*value2*"]'}, format="json")

assert response.status_code == 200, response.content

def test_query_issue_platform_title(self) -> None:
issue_title = "king of england"
occurrence, group_info = self.process_occurrence(
Expand Down
Loading