Skip to content

feat(attachment): Inline small attachments instead of uploading to objectstore#6165

Merged
tobias-wilfert merged 8 commits into
masterfrom
tobias-wilfert/feat/inline-small-attachments
Jul 3, 2026
Merged

feat(attachment): Inline small attachments instead of uploading to objectstore#6165
tobias-wilfert merged 8 commits into
masterfrom
tobias-wilfert/feat/inline-small-attachments

Conversation

@tobias-wilfert

@tobias-wilfert tobias-wilfert commented Jul 1, 2026

Copy link
Copy Markdown
Member

Fix: RELAY-255

@tobias-wilfert tobias-wilfert self-assigned this Jul 1, 2026
@linear-code

linear-code Bot commented Jul 1, 2026

Copy link
Copy Markdown

RELAY-255

Comment on lines +173 to +179
#[serde(
rename = "relay.attachment-inline.limit",
deserialize_with = "default_on_error",
skip_serializing_if = "is_default"
)]
pub attachment_inline_limit: u32,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Idea here is that we can roll this change out as is (NOOP) and once we set this value it would take effect. Would also allow us to experiment with different values.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Talked with Joris and David offline and making this a usize should be fine.

Comment thread relay-server/src/endpoints/minidump.rs
Comment thread relay-server/src/endpoints/minidump.rs Outdated
match upload_context.upload_decision(item.attachment_type()) {
UploadDecision::Inline => read_inline(field, item).await,
UploadDecision::Upload => {
let content_type = field.content_type().map(|ct| ct.essence_str().to_owned());

Copy link
Copy Markdown
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 want to use essence_str in general (we currently do it differently at a couple of spots in the new logi so I think we want to fix that in a follow up).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Plan: Do it like the rest of the code (ct.as_ref()) and as part of INGEST-983 clean this up overall.

@tobias-wilfert tobias-wilfert requested a review from jjbayer July 2, 2026 07:29
Comment thread relay-dynamic-config/src/global.rs Outdated
Comment thread relay-server/src/endpoints/minidump.rs
Comment on lines +28 to +51
/// The result of [`split_by_size`].
pub enum SizeSplit<S> {
/// The stream is less than limit and hence buffered into memory.
Small(Bytes),
/// The stream exceeds limit and hence is not buffered.
Large(S),
}

/// Buffers a stream if its size is less than `limit` bytes, else return the stream.
pub async fn split_by_size<S, E>(
stream: S,
limit: usize,
) -> Result<SizeSplit<impl Stream<Item = Result<Bytes, E>> + Send>, E>
where
S: Stream<Item = Result<Bytes, E>> + Send,
E: Send,
{
let (head, stream) = peek_n(stream, limit).await?;
if head.len() < limit {
Ok(SizeSplit::Small(head))
} else {
Ok(SizeSplit::Large(stream))
}
}

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.

I believe you can simplify the API by changing peek_n to return (Bytes, Option<Stream>), i.e. return None for the stream if there's nothing after head. reject_if_compressed can re-use the bytes obtained by the first call to peek_n.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Talked offline and while this would be really nice the issue is that if the initial peek peeks less bytes than what we need eventually this will not work. Which is the case since we want to roll this out with a peek of 0 bytes initially.

Co-authored-by: Joris Bayer <joris.bayer@sentry.io>
@tobias-wilfert

tobias-wilfert commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

For the bytes we get from peek_n we probably want to call validate_minidump, see: #6151 (comment) will be tackled as part of INGEST-983

@tobias-wilfert tobias-wilfert changed the title WIP: feat(attachment): Inline small attachments instead of uploading to objectstore feat(attachment): Inline small attachments instead of uploading to objectstore Jul 2, 2026
@tobias-wilfert

Copy link
Copy Markdown
Member Author

There are a bunch of merge conflicts I will still need to fix.

@tobias-wilfert tobias-wilfert marked this pull request as ready for review July 2, 2026 12:18
@tobias-wilfert tobias-wilfert requested a review from a team as a code owner July 2, 2026 12:18

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

Reviewed by Cursor Bugbot for commit 1d7a731. Configure here.

Comment thread relay-server/src/endpoints/minidump.rs
@tobias-wilfert tobias-wilfert requested a review from jjbayer July 2, 2026 12:53
@tobias-wilfert tobias-wilfert added this pull request to the merge queue Jul 3, 2026
Merged via the queue into master with commit c916bc4 Jul 3, 2026
35 checks passed
@tobias-wilfert tobias-wilfert deleted the tobias-wilfert/feat/inline-small-attachments branch July 3, 2026 09:05
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