Skip to content

Commit 0efb566

Browse files
Zylphrexiamrajjoshi
authored andcommitted
fix(eap): Handle quotes in typed attributes (#91482)
Colons were introduced to the tag keys and needs to be quoted. This makes sure the quoting is properly handled by removing it before using it as a key.
1 parent 254c256 commit 0efb566

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/sentry/search/eap/resolver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ def resolve_attribute(
801801
field_type = "string"
802802
else:
803803
field_type = None
804-
field = tag_match.group("tag") if tag_match else column
804+
# make sure to remove surrounding quotes if it's a tag
805+
field = tag_match.group("tag").strip('"') if tag_match else column
805806
if field is None:
806807
raise InvalidSearchQuery(f"Could not parse {column}")
807808
# Assume string if a type isn't passed. eg. tags[foo]

tests/snuba/api/endpoints/test_organization_events_span_indexed.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,3 +4547,37 @@ def test_app_start_fields(self):
45474547

45484548
assert meta["dataset"] == self.dataset
45494549
assert meta["dataset"] == self.dataset
4550+
4551+
def test_typed_attributes_with_colons(self):
4552+
span = self.create_span(
4553+
{
4554+
"data": {
4555+
"flag.evaluation.feature.organizations:foo": True,
4556+
},
4557+
},
4558+
start_ts=self.ten_mins_ago,
4559+
)
4560+
self.store_spans(
4561+
[
4562+
self.create_span(start_ts=self.ten_mins_ago),
4563+
span,
4564+
],
4565+
is_eap=self.is_eap,
4566+
)
4567+
4568+
response = self.do_request(
4569+
{
4570+
"field": ['tags["flag.evaluation.feature.organizations:foo",number]'],
4571+
"query": 'has:tags["flag.evaluation.feature.organizations:foo",number]',
4572+
"project": self.project.id,
4573+
"dataset": self.dataset,
4574+
}
4575+
)
4576+
assert response.status_code == 200, response.content
4577+
assert response.data["data"] == [
4578+
{
4579+
"id": span["span_id"],
4580+
"project.name": self.project.slug,
4581+
'tags["flag.evaluation.feature.organizations:foo",number]': 1,
4582+
},
4583+
]

0 commit comments

Comments
 (0)