Skip to content

Conversation

@tobias-wilfert
Copy link
Member

@tobias-wilfert tobias-wilfert commented Jan 26, 2026

Migrates the process_replay logic to our new processor architecture.

Follow ups:

  • Decide on if moving the relay-event-normalization/src/replay.rs logic makes sense
  • Avoid the store envelope for store-forward
  • Make the outcome counting consistent?

Fixes: INGEST-515

@tobias-wilfert tobias-wilfert self-assigned this Jan 26, 2026
@linear
Copy link

linear bot commented Jan 26, 2026

Comment on lines +34 to +36
/// There should be either 0 of both or 1 of both.
#[error("invalid item count")]
InvalidItemCount,
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we want a more granular error here for the (0,n) and (n,0) case since this error becomes DiscardReason::DuplicateItem which is misleading if the envelope has (0,1) of the (recording,event)

Comment on lines +59 to +67
/// The PII config for scrubbing the recording could not be loaded.
#[error("invalid pii config")]
PiiConfigError(PiiConfigError),

/// An error occurred during PII scrubbing of the Replay.
///
/// This error is usually returned when the PII configuration fails to parse.
#[error("failed to scrub PII: {0}")]
CouldNotScrub(String),
Copy link
Member Author

Choose a reason for hiding this comment

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

These are very similar but one becomes DiscardReason::InvalidReplayEventPii and the other DiscardReason::ProjectStatePii I think just having the later and getting rid of InvalidReplayEventPii should be fine?


// FIXME: Might not need to be a vec in the future.
/// Expanded replays
replays: Vec<ExpandedReplay>,
Copy link
Member Author

Choose a reason for hiding this comment

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

I think technically this can be just one instead of a vec. See the comment in the expand function.

Comment on lines +60 to +65
let envelope = self.serialize_envelope(ctx)?;
let envelope = ManagedEnvelope::from(envelope).into_processed();

s.store(crate::services::store::StoreEnvelope { envelope });

Ok(())
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can avoid the StoreEnvelope here.

@tobias-wilfert tobias-wilfert changed the title WIP: migrate process_replay feat(processor): Migrate process_replay Jan 29, 2026
@tobias-wilfert tobias-wilfert marked this pull request as ready for review January 29, 2026 07:27
@tobias-wilfert tobias-wilfert requested a review from a team as a code owner January 29, 2026 07:27
Copy link

@cursor cursor bot left a comment

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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

let mut item = Item::new(ItemType::ReplayVideo);
item.set_payload(ContentType::MsgPack, payload);
item
}
Copy link

Choose a reason for hiding this comment

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

ReplayVideo content type changed from OctetStream to MsgPack

Medium Severity

The create_replay_video_item function sets ContentType::MsgPack for ReplayVideo items, but the old deleted code in relay-server/src/services/processor/replay.rs used ContentType::OctetStream. This is a behavior change that could affect downstream consumers that check the content type header, even though the actual payload format (MessagePack) hasn't changed. For a migration PR intending to preserve behavior, this is an unintended change.

Fix in Cursor Fix in Web

);
records.reject_err(Error::FailedToSerializeReplay, replay);
}
}
Copy link

Choose a reason for hiding this comment

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

Serialization failure now rejects instead of forwarding original

Medium Severity

The old code had a fallback when replay event serialization (to_json()) failed: it would log an error and return the original unprocessed payload, allowing the item to continue being forwarded. The new code rejects the replay with Error::FailedToSerializeReplay which maps to DiscardReason::Internal. This means serialization failures that previously resulted in forwarding (potentially unprocessed) data now result in the item being completely dropped with an outcome recorded.

Fix in Cursor Fix in Web

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.

2 participants