Skip to content

Commit 2b7077a

Browse files
authored
fix(replays): Return an error if an unsupported click attribute is selected (#53443)
1 parent bf32e6c commit 2b7077a

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/sentry/replays/lib/selector/parse.py

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ def visit_attribute(query: QueryType, attribute: Attrib) -> None:
8787
query.testid = attribute.value
8888
elif attrib == "title":
8989
query.title = attribute.value
90+
else:
91+
raise ParseError(
92+
"Invalid attribute specified. Only alt, aria-label, role, data-testid, data-test-id, "
93+
"and title are supported."
94+
)
9095

9196

9297
def visit_class(query: QueryType, class_: Class) -> None:

tests/sentry/replays/test_organization_replay_index.py

+15
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,21 @@ def test_get_replays_filter_clicks_unsupported_selector(self):
11691169
== b'{"detail":"Only attribute, class, id, and tag name selectors are supported."}'
11701170
), query
11711171

1172+
def test_get_replays_filter_clicks_unsupported_attribute_selector(self):
1173+
"""Assert replays only supports a subset of selector syntax."""
1174+
project = self.create_project(teams=[self.team])
1175+
self.store_replays(mock_replay(datetime.datetime.now(), project.id, uuid.uuid4().hex))
1176+
1177+
with self.feature(REPLAYS_FEATURES):
1178+
queries = ["click.selector:div[xyz=test]"]
1179+
for query in queries:
1180+
response = self.client.get(self.url + f"?field=id&query={query}")
1181+
assert response.status_code == 400, query
1182+
assert response.content == (
1183+
b'{"detail":"Invalid attribute specified. Only alt, aria-label, role, '
1184+
b'data-testid, data-test-id, and title are supported."}'
1185+
), query
1186+
11721187
def test_get_replays_filter_clicks_unsupported_operators(self):
11731188
"""Assert replays only supports a subset of selector syntax."""
11741189
project = self.create_project(teams=[self.team])

0 commit comments

Comments
 (0)