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
17 changes: 11 additions & 6 deletions src/sentry/replays/endpoints/organization_replay_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def query_replay_instance_eap(
select = [
Column("replay_id"),
Function("min", parameters=[Column("project_id")], alias="agg_project_id"),
Function("min", parameters=[Column("timestamp")], alias="started_at"),
Function("max", parameters=[Column("timestamp")], alias="finished_at"),
Function("min", parameters=[Column("sentry.timestamp")], alias="started_at"),
Function("max", parameters=[Column("sentry.timestamp")], alias="finished_at"),
Function("count", parameters=[Column("segment_id")], alias="count_segments"),
Function("sum", parameters=[Column("count_error_events")], alias="count_errors"),
Function("sum", parameters=[Column("count_warning_events")], alias="count_warnings"),
Expand All @@ -51,7 +51,10 @@ def query_replay_instance_eap(
Column("click_is_dead"),
Function(
"greaterOrEquals",
[Column("timestamp"), int(datetime(year=2023, month=7, day=24).timestamp())],
[
Column("sentry.timestamp"),
int(datetime(year=2023, month=7, day=24).timestamp()),
],
),
],
alias="count_dead_clicks",
Expand All @@ -62,7 +65,10 @@ def query_replay_instance_eap(
Column("click_is_rage"),
Function(
"greaterOrEquals",
[Column("timestamp"), int(datetime(year=2023, month=7, day=24).timestamp())],
[
Column("sentry.timestamp"),
int(datetime(year=2023, month=7, day=24).timestamp()),
],
),
],
alias="count_rage_clicks",
Expand All @@ -84,8 +90,7 @@ def query_replay_instance_eap(
attribute_types={
"replay_id": str,
"project_id": int,
"timestamp": int,
"replay_start_timestamp": int,
"sentry.timestamp": int,
"segment_id": int,
"is_archived": int,
"count_error_events": int,
Expand Down
1 change: 0 additions & 1 deletion src/sentry/testutils/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3860,7 +3860,6 @@ def create_eap_replay_breadcrumb(
"replay_id": replay_id,
"segment_id": segment_id,
"project_id": project.id,
"timestamp": int(timestamp.timestamp()),
"category": category,
}

Comment on lines 3860 to 3865
Copy link

Choose a reason for hiding this comment

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

Bug: The create_eap_replay_breadcrumb() helper is missing the sentry.timestamp attribute in its generated attributes dictionary, causing queries to return NULL for timestamp aggregations.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The create_eap_replay_breadcrumb() helper in src/sentry/testutils/cases.py no longer populates the sentry.timestamp attribute in the attributes dictionary. This omission occurs because the line "timestamp": int(timestamp.timestamp()) was removed without a replacement that adds sentry.timestamp to attributes_proto. Consequently, queries in organization_replay_details.py that depend on min(sentry.timestamp) and max(sentry.timestamp) will return NULL for started_at and finished_at. This will cause related test assertions to fail and the replay details UI to display incorrect NULL values.

💡 Suggested Fix

In create_eap_replay_breadcrumb(), add attributes_proto["sentry.timestamp"] = AnyValue(int_value=int(timestamp.timestamp() * 1e9)) to correctly populate the sentry.timestamp attribute, similar to OurLogTestCase.create_ourlog().

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/sentry/testutils/cases.py#L3860-L3865

Potential issue: The `create_eap_replay_breadcrumb()` helper in
`src/sentry/testutils/cases.py` no longer populates the `sentry.timestamp` attribute in
the `attributes` dictionary. This omission occurs because the line `"timestamp":
int(timestamp.timestamp())` was removed without a replacement that adds
`sentry.timestamp` to `attributes_proto`. Consequently, queries in
`organization_replay_details.py` that depend on `min(sentry.timestamp)` and
`max(sentry.timestamp)` will return `NULL` for `started_at` and `finished_at`. This will
cause related test assertions to fail and the replay details UI to display incorrect
`NULL` values.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3644401

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def test_eap_replay_query(self) -> None:
assert "started_at" in replay1_data
assert "finished_at" in replay1_data

assert replay1_data["started_at"] is not None, "started_at should not be None"
assert replay1_data["finished_at"] is not None, "finished_at should not be None"

assert replay1_data["count_dead_clicks"] == 3, "2 DEAD_CLICK + 1 RAGE_CLICK = 3 dead"
assert replay1_data["count_rage_clicks"] == 1, "1 RAGE_CLICK = 1 rage"

Expand Down
Loading