Skip to content

Commit 2546709

Browse files
authored
ref(flags): Remove quoted flags syntax from grammar (#93619)
Depends on: #93616
1 parent 56cf784 commit 2546709

File tree

4 files changed

+12
-89
lines changed

4 files changed

+12
-89
lines changed

src/sentry/api/event_search.py

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,9 @@
140140
141141
# the quoted variant is here to for backwards compatibility,
142142
# and can be removed once we're sure it's no longer in use
143-
explicit_flag_key_unquoted = "flags" open_bracket escaped_key closed_bracket
144-
explicit_flag_key_quoted = "flags" open_bracket quoted_key closed_bracket
145-
explicit_flag_key = explicit_flag_key_unquoted / explicit_flag_key_quoted
146-
explicit_string_flag_key_unquoted = "flags" open_bracket escaped_key spaces comma spaces "string" closed_bracket
147-
explicit_string_flag_key_quoted = "flags" open_bracket quoted_key spaces comma spaces "string" closed_bracket
148-
explicit_string_flag_key = explicit_string_flag_key_unquoted / explicit_string_flag_key_quoted
149-
explicit_number_flag_key_unquoted = "flags" open_bracket escaped_key spaces comma spaces "number" closed_bracket
150-
explicit_number_flag_key_quoted = "flags" open_bracket quoted_key spaces comma spaces "number" closed_bracket
151-
explicit_number_flag_key = explicit_number_flag_key_unquoted / explicit_number_flag_key_quoted
143+
explicit_flag_key = "flags" open_bracket escaped_key closed_bracket
144+
explicit_string_flag_key = "flags" open_bracket escaped_key spaces comma spaces "string" closed_bracket
145+
explicit_number_flag_key = "flags" open_bracket escaped_key spaces comma spaces "number" closed_bracket
152146
153147
explicit_tag_key = "tags" open_bracket escaped_key closed_bracket
154148
explicit_string_tag_key = "tags" open_bracket escaped_key spaces comma spaces "string" closed_bracket
@@ -1408,19 +1402,7 @@ def visit_explicit_number_tag_key(
14081402
) -> SearchKey:
14091403
return SearchKey(f"tags[{children[2]},number]")
14101404

1411-
def visit_explicit_flag_key_unquoted(
1412-
self,
1413-
node: Node,
1414-
children: tuple[
1415-
Node, # "flags"
1416-
str, # [
1417-
str, # escaped_key
1418-
str, # ]
1419-
],
1420-
) -> SearchKey:
1421-
return SearchKey(f"flags[{children[2]}]")
1422-
1423-
def visit_explicit_flag_key_quoted(
1405+
def visit_explicit_flag_key(
14241406
self,
14251407
node: Node,
14261408
children: tuple[
@@ -1432,30 +1414,7 @@ def visit_explicit_flag_key_quoted(
14321414
) -> SearchKey:
14331415
return SearchKey(f"flags[{children[2]}]")
14341416

1435-
def visit_explicit_flag_key(
1436-
self,
1437-
node: Node,
1438-
children: tuple[SearchKey],
1439-
) -> SearchKey:
1440-
return children[0]
1441-
1442-
def visit_explicit_string_flag_key_unquoted(
1443-
self,
1444-
node: Node,
1445-
children: tuple[
1446-
Node, # "flags"
1447-
str, # '['
1448-
str, # escaped_key
1449-
str, # ' '
1450-
Node, # ','
1451-
str, # ' '
1452-
Node, # "string"
1453-
str, # ']'
1454-
],
1455-
) -> SearchKey:
1456-
return SearchKey(f"flags[{children[2]},string]")
1457-
1458-
def visit_explicit_string_flag_key_quoted(
1417+
def visit_explicit_string_flag_key(
14591418
self,
14601419
node: Node,
14611420
children: tuple[
@@ -1471,30 +1430,7 @@ def visit_explicit_string_flag_key_quoted(
14711430
) -> SearchKey:
14721431
return SearchKey(f"flags[{children[2]},string]")
14731432

1474-
def visit_explicit_string_flag_key(
1475-
self,
1476-
node: Node,
1477-
children: tuple[SearchKey],
1478-
) -> SearchKey:
1479-
return children[0]
1480-
1481-
def visit_explicit_number_flag_key_unquoted(
1482-
self,
1483-
node: Node,
1484-
children: tuple[
1485-
Node, # "flags"
1486-
str, # '['
1487-
str, # escaped_key
1488-
str, # ' '
1489-
Node, # ','
1490-
str, # ' '
1491-
Node, # "number"
1492-
str, # ']'
1493-
],
1494-
) -> SearchKey:
1495-
return SearchKey(f"flags[{children[2]},number]")
1496-
1497-
def visit_explicit_number_flag_key_quoted(
1433+
def visit_explicit_number_flag_key(
14981434
self,
14991435
node: Node,
15001436
children: tuple[
@@ -1510,13 +1446,6 @@ def visit_explicit_number_flag_key_quoted(
15101446
) -> SearchKey:
15111447
return SearchKey(f"flags[{children[2]},number]")
15121448

1513-
def visit_explicit_number_flag_key(
1514-
self,
1515-
node: Node,
1516-
children: tuple[SearchKey],
1517-
) -> SearchKey:
1518-
return children[0]
1519-
15201449
def visit_aggregate_key(
15211450
self,
15221451
node: Node,

tests/sentry/api/test_event_search.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,12 +1072,6 @@ def test_invalid_translate_wildcard_as_clickhouse_pattern(pattern):
10721072
pytest.param("flags[foo:bar,string]:true", "flags[foo:bar,string]", "true"),
10731073
pytest.param("flags[foo,number]:0", "flags[foo,number]", "0"),
10741074
pytest.param("flags[foo:bar,number]:0", "flags[foo:bar,number]", "0"),
1075-
# the quoted versions are supported for flags for backwards compatibility
1076-
pytest.param('flags["foo"]:true', "flags[foo]", "true"),
1077-
pytest.param('flags["foo",string]:true', "flags[foo,string]", "true"),
1078-
pytest.param('flags["foo:bar",string]:true', "flags[foo:bar,string]", "true"),
1079-
pytest.param('flags["foo",number]:0', "flags[foo,number]", "0"),
1080-
pytest.param('flags["foo:bar",number]:0', "flags[foo:bar,number]", "0"),
10811075
],
10821076
)
10831077
def test_handles_special_character_in_tags_and_flags(query, key, value):

tests/sentry/issues/endpoints/test_organization_group_index.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4051,15 +4051,15 @@ def test_flags_and_tags_query(self, _: MagicMock) -> None:
40514051
)
40524052

40534053
with self.feature({"organizations:issue-search-snuba": False}):
4054-
response = self.get_success_response(query='flags["test:flag"]:true')
4054+
response = self.get_success_response(query="flags[test:flag]:true")
40554055
assert len(json.loads(response.content)) == 1
4056-
response = self.get_success_response(query='flags["test:flag"]:false')
4056+
response = self.get_success_response(query="flags[test:flag]:false")
40574057
assert len(json.loads(response.content)) == 0
40584058

40594059
with self.feature({"organizations:issue-search-snuba": True}):
4060-
response = self.get_success_response(query='flags["test:flag"]:true')
4060+
response = self.get_success_response(query="flags[test:flag]:true")
40614061
assert len(json.loads(response.content)) == 1
4062-
response = self.get_success_response(query='flags["test:flag"]:false')
4062+
response = self.get_success_response(query="flags[test:flag]:false")
40634063
assert len(json.loads(response.content)) == 0
40644064

40654065
def test_postgres_query_timeout(self, mock_query: MagicMock) -> None:

tests/sentry/issues/endpoints/test_organization_issues_count.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ def test_issue_count_flag_query(self) -> None:
2828
project_id=self.project.id,
2929
)
3030

31-
response = self.client.get(self.url + '?query=flags["test:flag"]:true')
31+
response = self.client.get(self.url + "?query=flags[test:flag]:true")
3232
assert response.status_code == 200
33-
assert response.json() == {'flags["test:flag"]:true': 1}
33+
assert response.json() == {"flags[test:flag]:true": 1}

0 commit comments

Comments
 (0)