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
3 changes: 2 additions & 1 deletion src/sentry/api/event_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,8 @@ def to_list(value):
projects = get_projects(params)
condition = ["project_id", "=", projects.get(term.value.value)]
kwargs["conditions"].append(condition)
elif name == "issue.id":
elif name == "issue.id" and term.value.value != "":

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you also check the operator? The !has:issue.id expression will fall into this case as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So both !has:issue.id and has.issue.id have the same name/value, but the operator changes, so both will get excluded by this elif here, and caught by the else later.

  • Added test to show this 👍

Comment thread
logicalbomb marked this conversation as resolved.
# A blank term value means that this is a has filter
kwargs["group_ids"].extend(to_list(term.value.value))
elif name in FIELD_ALIASES:
converted_filter = convert_aggregate_filter_to_snuba_query(term, True)
Expand Down
10 changes: 10 additions & 0 deletions tests/sentry/api/test_event_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,16 @@ def test_has(self):
def test_not_has(self):
assert get_filter("!has:release").conditions == [[["isNull", ["release"]], "=", 1]]

def test_has_issue_id(self):
has_issue_filter = get_filter("has:issue.id")
assert has_issue_filter.group_ids == []
assert has_issue_filter.conditions == [[["isNull", ["issue.id"]], "!=", 1]]

def test_not_has_issue_id(self):
has_issue_filter = get_filter("!has:issue.id")
assert has_issue_filter.group_ids == []
assert has_issue_filter.conditions == [[["isNull", ["issue.id"]], "=", 1]]

def test_message_negative(self):
assert get_filter('!message:"post_process.process_error HTTPError 403"').conditions == [
[
Expand Down