Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(replays): Remove timestamp validation for dates from the future #4196

Merged
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
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased

Check failure on line 3 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / Changelogs

Missing changelog entry.

Please consider adding a changelog entry for the next release.

Check failure on line 3 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / Changelogs

Missing changelog entry.

Please consider adding a changelog entry for the next release.

**Breaking Changes**:

Expand All @@ -9,7 +9,6 @@
**Bug Fixes**

- Allow profile chunks without release. ([#4155](https://github.com/getsentry/relay/pull/4155))
- Add validation for timestamps sent from the future. ([#4163](https://github.com/getsentry/relay/pull/4163))

**Features:**

Expand Down
49 changes: 1 addition & 48 deletions relay-event-normalization/src/replay.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Validation and normalization of [`Replay`] events.

use chrono::Utc;
use std::net::IpAddr as StdIpAddr;

use relay_event_schema::processor::{self, ProcessingState, Processor};
Expand Down Expand Up @@ -36,10 +35,6 @@ pub enum ReplayError {
/// This erorr is usually returned when the PII configuration fails to parse.
#[error("failed to scrub PII: {0}")]
CouldNotScrub(String),

/// Date in the future.
#[error("date was from the future")]
DateInTheFuture,
}

/// Checks if the Replay event is structurally valid.
Expand Down Expand Up @@ -81,14 +76,6 @@ pub fn validate(replay: &Replay) -> Result<(), ReplayError> {
));
}

if replay
.timestamp
.value()
.map_or(false, |v| v.into_inner() > Utc::now())
{
return Err(ReplayError::DateInTheFuture);
}

Ok(())
}

Expand Down Expand Up @@ -184,7 +171,7 @@ fn normalize_type(replay: &mut Replay) {
mod tests {
use std::net::{IpAddr, Ipv4Addr};

use chrono::{Duration, TimeZone, Utc};
use chrono::{TimeZone, Utc};
use insta::assert_json_snapshot;
use relay_protocol::{assert_annotated_snapshot, get_value, SerializableAnnotated};
use uuid::Uuid;
Expand Down Expand Up @@ -452,40 +439,6 @@ mod tests {
assert!(validation_result.is_err());
}

#[test]
fn test_future_timestamp_validation() {
let future_time = Utc::now() + Duration::hours(1);
let json = format!(
r#"{{
"event_id": "52df9022835246eeb317dbd739ccd059",
"replay_id": "52df9022835246eeb317dbd739ccd059",
"segment_id": 0,
"replay_type": "session",
"error_sample_rate": 0.5,
"session_sample_rate": 0.5,
"timestamp": {},
"replay_start_timestamp": 946684800.0,
"urls": ["localhost:9000"],
"error_ids": ["test"],
"trace_ids": [],
"platform": "myplatform",
"release": "myrelease",
"dist": "mydist",
"environment": "myenv",
"tags": [
[
"tag",
"value"
]
]
}}"#,
future_time.timestamp()
);
let mut replay = Annotated::<Replay>::from_json(&json).unwrap();
let validation_result = validate(replay.value_mut().as_mut().unwrap());
assert!(validation_result.is_err());
}

#[test]
fn test_trace_id_validation() {
// NOTE: Interfaces will be tested separately.
Expand Down
4 changes: 0 additions & 4 deletions relay-server/src/services/outcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,6 @@ pub enum DiscardReason {
InvalidReplayRecordingEvent,
InvalidReplayVideoEvent,

/// (Relay) The event's timestamp was too far in the future.
DateInTheFuture,

/// (Relay) Profiling related discard reasons
Profiling(&'static str),

Expand Down Expand Up @@ -506,7 +503,6 @@ impl DiscardReason {
DiscardReason::Profiling(reason) => reason,
DiscardReason::InvalidSpan => "invalid_span",
DiscardReason::FeatureDisabled(_) => "feature_disabled",
DiscardReason::DateInTheFuture => "date_in_the_future",
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions relay-server/src/services/processor/replay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ fn handle_replay_event_item(
ReplayError::InvalidPayload(_) => {
ProcessingError::InvalidReplay(DiscardReason::InvalidReplayEvent)
}
ReplayError::DateInTheFuture => {
ProcessingError::InvalidReplay(DiscardReason::DateInTheFuture)
}
})
}
}
Expand Down
Loading