-
Notifications
You must be signed in to change notification settings - Fork 120
fix: Don't synthesize event IDs for requires_event items
#6350
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
Changes from all commits
9589c17
238e9eb
e583a93
93d3493
c5a7a25
15fff07
003fb7c
25f185e
cb4e6ae
61157e0
e8d3794
47bee86
f6c5a94
c652571
25fe72a
12ab51e
61ca1f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,24 @@ | ||
| use relay_event_normalization::replay; | ||
|
|
||
| use crate::processing::replays::{Error, ExpandedReplay, Result}; | ||
| use crate::statsd::RelayCounters; | ||
| use crate::utils::client_name_tag; | ||
|
|
||
| /// Checks the structural validity of a replay, rejects it if invalid. | ||
| pub fn validate(replay: &ExpandedReplay) -> Result<()> { | ||
| let has_event_id = replay.headers.event_id().is_some(); | ||
|
|
||
| // Temporary counter to figure out which SDKs are sending replays without event IDs. | ||
| relay_statsd::metric!( | ||
| counter(RelayCounters::Replay) += 1, | ||
| sdk = client_name_tag(replay.headers.meta().client_name()), | ||
| has_event_id = has_event_id.to_string(), | ||
| ); | ||
|
|
||
| if !has_event_id { | ||
| return Err(Error::NoEventId); | ||
| } | ||
|
Comment on lines
+18
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: The new validation in Suggested FixModify the validation logic in Prompt for AI Agent
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They were already meant to be removed, this check existed the entire time. It just didn't work because we invented an event ID on ingestion. |
||
|
|
||
| let Some(event) = replay.payload.event() else { | ||
| return Ok(()); | ||
| }; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,12 +4,15 @@ use relay_cogs::{AppFeature, FeatureWeights}; | |
| use relay_quotas::RateLimits; | ||
|
|
||
| use crate::envelope::{EnvelopeHeaders, Item, ItemType}; | ||
| use crate::managed::{Counted, Managed, ManagedEnvelope, OutcomeError, Quantities, Rejected}; | ||
| use crate::managed::{ | ||
| Counted, Managed, ManagedEnvelope, ManagedResult, OutcomeError, Quantities, Rejected, | ||
| }; | ||
| use crate::processing::{Context, CountRateLimited, Output, Processor, QuotaRateLimiter}; | ||
| use crate::services::outcome::Outcome; | ||
|
|
||
| mod forward; | ||
| mod process; | ||
| mod validate; | ||
|
|
||
| pub use process::process_user_reports; | ||
|
|
||
|
|
@@ -20,7 +23,6 @@ pub enum Error { | |
| RateLimited(RateLimits), | ||
|
|
||
| /// The envelope did not contain an event ID. | ||
| #[cfg(feature = "processing")] | ||
| #[error("missing event ID")] | ||
| NoEventId, | ||
| } | ||
|
|
@@ -34,9 +36,8 @@ impl OutcomeError for Error { | |
| let reason_code = limits.longest().and_then(|limit| limit.reason_code.clone()); | ||
| Some(Outcome::RateLimited(reason_code)) | ||
| } | ||
| #[cfg(feature = "processing")] | ||
| Self::NoEventId => Some(Outcome::Invalid( | ||
| crate::services::outcome::DiscardReason::Internal, | ||
| crate::services::outcome::DiscardReason::InvalidEventId, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For future reference, these are deprecated and we want to probably grab the EventID from the payload rather than the headers: INGEST-1174. |
||
| )), | ||
| }; | ||
| (outcome, self) | ||
|
|
@@ -91,6 +92,7 @@ impl Processor for UserReportsProcessor { | |
| mut reports: Managed<Self::Input>, | ||
| ctx: Context<'_>, | ||
| ) -> Result<Output<Self::Output>, Rejected<Self::Error>> { | ||
| validate::validate(&reports).reject(&reports)?; | ||
| process::process(&mut reports); | ||
|
|
||
| let reports = self.limiter.enforce_quotas(reports, ctx).await?; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| use crate::processing::user_reports::{Error, SerializedUserReports}; | ||
| use crate::statsd::RelayCounters; | ||
| use crate::utils::client_name_tag; | ||
|
|
||
| /// Checks that the user reports contain an event ID. | ||
| pub fn validate(reports: &SerializedUserReports) -> Result<(), Error> { | ||
| let has_event_id = reports.headers.event_id().is_some(); | ||
|
|
||
| // Temporary counter to figure out which SDKs are sending user reports without event IDs. | ||
| relay_statsd::metric!( | ||
| counter(RelayCounters::UserReport) += 1, | ||
| sdk = client_name_tag(reports.headers.meta().client_name()), | ||
| has_event_id = has_event_id.to_string(), | ||
| ); | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| if !has_event_id { | ||
| return Err(Error::NoEventId); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.