Skip to content

Commit

Permalink
bug(replays): Fix 500 error when marshaling tags field (#45097)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmanallen authored Feb 28, 2023
1 parent 8e1ef19 commit a345807
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sentry/replays/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _activity_score():
"browser": ["browser_name", "browser_version"],
"device": ["device_name", "device_brand", "device_family", "device_model"],
"sdk": ["sdk_name", "sdk_version"],
"tags": ["tags.key", "tags.value"],
"tags": ["tk", "tv"],
# Nested fields. Useful for selecting searchable fields.
"user.id": ["user_id"],
"user.email": ["user_email"],
Expand Down
42 changes: 42 additions & 0 deletions tests/sentry/replays/test_organization_replay_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,48 @@ def test_get_replays_browse_screen_fields(self):
assert "ip" in response_data["data"][0]["user"]
assert "display_name" in response_data["data"][0]["user"]

def test_get_replays_tags_field(self):
"""Test replay response with fields requested in production."""
project = self.create_project(teams=[self.team])

replay1_id = uuid.uuid4().hex
seq1_timestamp = datetime.datetime.now() - datetime.timedelta(seconds=22)
seq2_timestamp = datetime.datetime.now() - datetime.timedelta(seconds=5)
self.store_replays(
mock_replay(
seq1_timestamp,
project.id,
replay1_id,
urls=[
"http://localhost:3000/",
"http://localhost:3000/login",
],
tags={"test": "hello", "other": "hello"},
)
)
self.store_replays(
mock_replay(
seq2_timestamp,
project.id,
replay1_id,
urls=["http://localhost:3000/"],
tags={"test": "world", "other": "hello"},
)
)

with self.feature(REPLAYS_FEATURES):
response = self.client.get(self.url + "?field=tags")
assert response.status_code == 200

response_data = response.json()
assert "data" in response_data
assert len(response_data["data"]) == 1

assert len(response_data["data"][0]) == 1
assert "tags" in response_data["data"][0]
assert response_data["data"][0]["tags"]["test"] == ["world", "hello"]
assert response_data["data"][0]["tags"]["other"] == ["hello"]

def test_get_replays_minimum_field_set(self):
"""Test replay response with fields requested in production."""
project = self.create_project(teams=[self.team])
Expand Down

0 comments on commit a345807

Please sign in to comment.