Skip to content

fix: Don't synthesize event IDs for requires_event items - #6350

Merged
loewenheim merged 17 commits into
masterfrom
sebastian/attachment-null-id
Sep 3, 2026
Merged

fix: Don't synthesize event IDs for requires_event items#6350
loewenheim merged 17 commits into
masterfrom
sebastian/attachment-null-id

Conversation

@loewenheim

Copy link
Copy Markdown
Contributor

Currently Relay fills in missing event IDs on envelopes if there are items present for which requires_event is true. This seems like a mistake both theoretically and practically:

  1. An item needing to be associated with an event isn't a good reason to invent an event ID if you don't have one.
  2. Filling in this ID means that we can't reject "orphaned" attachments which are sent without an event ID; the check exists but it can never trip.

This PR fixes the problem by gating the synthesis behind creates_event (false for attachments in general) instead of requires_event (true for all attachments).

It also makes some additional improvements:

  1. The same check is added to process so these attachments are rejected as early as possible.
  2. The discard reason for the missing event ID is changed from Internal to InvalidEventId.

Finally, it also adds an integration test.

Effect on other item types

Changing the event ID synthesis from requires_event to creates_event also means that envelopes containing solely FormData, UserReport, Profile, or ReplayEvent items will no longer have an event ID synthesized. In the case of UserReport and ReplayEvent there is already a check that could previously never trip, exactly like the one for attachments.

Fixes #6349. Fixes RELAY-278.

@loewenheim
loewenheim requested a review from a team as a code owner September 3, 2026 10:32
@linear-code

linear-code Bot commented Sep 3, 2026

Copy link
Copy Markdown

RELAY-278

@loewenheim loewenheim self-assigned this Sep 3, 2026
Comment thread relay-server/src/envelope/mod.rs
@tobias-wilfert

Copy link
Copy Markdown
Member

nit: I think having a metric/log in the existing NoEventId checks might be nice, just to confirm for us we did not break anything for the users.

#[cfg(feature = "processing")]
Self::NoEventId => Some(Outcome::Invalid(
crate::services::outcome::DiscardReason::Internal,
crate::services::outcome::DiscardReason::InvalidEventId,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a534507. Configure here.

Comment thread relay-server/src/processing/user_reports/validate.rs
Comment thread relay-server/src/processing/user_reports/validate.rs Outdated
@loewenheim
loewenheim force-pushed the sebastian/attachment-null-id branch from a534507 to 25fe72a Compare September 3, 2026 12:04
@loewenheim
loewenheim requested a review from jjbayer September 3, 2026 12:04
Comment thread relay-server/src/envelope/mod.rs
Comment thread relay-server/src/processing/replays/validate.rs Outdated
Comment on lines +18 to +20
if !has_event_id {
return Err(Error::NoEventId);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The new validation in validate.rs unconditionally rejects replays without an event_id, breaking backward compatibility for StandaloneRecording payloads from some SDKs.
Severity: HIGH

Suggested Fix

Modify the validation logic in validate::validate to not require an event_id for StandaloneRecording payloads. The check for replay.payload.event() should happen before the event_id check. If replay.payload.event() is None, the function should return Ok(()) to allow these specific payloads through, preserving backward compatibility.

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: relay-server/src/processing/replays/validate.rs#L18-L20

Potential issue: A new validation check in
`relay-server/src/processing/replays/validate.rs` requires all replays to have an
`event_id`. This check is performed before the payload type is evaluated. As a result,
`StandaloneRecording` payloads, which are intentionally supported for backward
compatibility with older SDKs and may not have an `event_id`, will be incorrectly
rejected. This contradicts a comment in `process.rs` which explicitly states this
support was added to "not break" SDKs that send recording items without event items.
These replays will be discarded with an `Error::NoEventId`.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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.

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
@loewenheim
loewenheim enabled auto-merge September 3, 2026 13:23
@loewenheim
loewenheim added this pull request to the merge queue Sep 3, 2026
Merged via the queue into master with commit 9f2590d Sep 3, 2026
50 of 53 checks passed
@loewenheim
loewenheim deleted the sebastian/attachment-null-id branch September 3, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter standalone attachments without an event ID

3 participants