Skip to content

feat(minidump): Guard against compressed minidump streams#5984

Open
tobias-wilfert wants to merge 9 commits into
masterfrom
tobias-wilfert/feat/no-compressed-streams
Open

feat(minidump): Guard against compressed minidump streams#5984
tobias-wilfert wants to merge 9 commits into
masterfrom
tobias-wilfert/feat/no-compressed-streams

Conversation

@tobias-wilfert
Copy link
Copy Markdown
Member

Adds a check to ensure we are not streaming compressed minidumps to objectstore (since neither it not symbolicator can currently handle them).

FIX INGEST-891

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 12, 2026

INGEST-891

@tobias-wilfert tobias-wilfert self-assigned this May 12, 2026
@tobias-wilfert tobias-wilfert requested a review from jjbayer May 12, 2026 11:24
project_id = 42
minidump_content = b"MDMP content"
log_content = b"Some log file content"
log_content = b"\x1f\x8b Some log file content"
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.

Add this to ensure that compressed attachment still work.

Comment on lines +362 to +364
Err(_) => {
return Err(item.reject_err(Outcome::Invalid(DiscardReason::InvalidMinidump)));
}
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.

We also reject the item here if we just fail to read for the stream for any reason, but I think that is ok.

Comment thread relay-server/src/endpoints/minidump.rs Outdated
Comment thread relay-server/src/endpoints/minidump.rs Outdated
}
}
let head = head.freeze();
let replay = stream::once(future::ready(Ok(head.clone()))).chain(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.

This is pretty elegant!

Comment thread relay-server/src/endpoints/minidump.rs Outdated
Comment on lines +113 to +116
if head.starts_with(GZIP_MAGIC_HEADER)
|| head.starts_with(XZ_MAGIC_HEADER)
|| head.starts_with(BZIP2_MAGIC_HEADER)
|| head.starts_with(ZSTD_MAGIC_HEADER)
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.

nit: You could put this in a helper function get_compression(data: &[u8]) -> Option<HttpEncoding> and share the helper with decoder_from.

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.

Not sure we can use it in decoder_from since that logic is slightly more sophisticated:

/// Creates a decoder based on the magic bytes the minidump payload
fn decoder_from(minidump_data: Bytes) -> Option<Box<dyn Read>> {
if minidump_data.starts_with(GZIP_MAGIC_HEADER) {
return Some(Box::new(GzDecoder::new(Cursor::new(minidump_data))));
} else if minidump_data.starts_with(XZ_MAGIC_HEADER) {
return Some(Box::new(XzDecoder::new(Cursor::new(minidump_data))));
} else if minidump_data.starts_with(BZIP2_MAGIC_HEADER) {
return Some(Box::new(BzDecoder::new(Cursor::new(minidump_data))));
} else if minidump_data.starts_with(ZSTD_MAGIC_HEADER) {
return match ZstdDecoder::new(Cursor::new(minidump_data)) {
Ok(decoder) => Some(Box::new(decoder)),
Err(ref err) => {
relay_log::error!(error = err as &dyn Error, "failed to create ZstdDecoder");
None
}
};
}
None
}

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.

My thinking was something like

fn decoder_from(minidump_data: Bytes) -> Option<Box<dyn Read>> {
    match get_compression(minidump_data) {
        HttpEncoding::Gzip => Some(Box::new(GzDecoder::new(Cursor::new(minidump_data))))

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.

Discussed offline, we're hesitant to add uncommon variants to the HttpEncoding enum so this would require a separate enum -> not worth the effort.

tobias-wilfert and others added 3 commits May 12, 2026 13:52
@tobias-wilfert tobias-wilfert marked this pull request as ready for review May 12, 2026 12:31
@tobias-wilfert tobias-wilfert requested a review from a team as a code owner May 12, 2026 12:31
Comment thread relay-server/src/endpoints/minidump.rs
Comment thread relay-server/src/endpoints/minidump.rs
Comment thread relay-server/src/endpoints/minidump.rs
Comment thread relay-server/src/endpoints/minidump.rs
Comment thread tests/integration/test_minidump.py
Comment thread relay-server/src/endpoints/minidump.rs
Copy link
Copy Markdown

@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 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 dcbb783. Configure here.

Comment thread relay-server/src/endpoints/minidump.rs
Comment on lines +113 to +116
if head.starts_with(GZIP_MAGIC_HEADER)
|| head.starts_with(XZ_MAGIC_HEADER)
|| head.starts_with(BZIP2_MAGIC_HEADER)
|| head.starts_with(ZSTD_MAGIC_HEADER)
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.

Discussed offline, we're hesitant to add uncommon variants to the HttpEncoding enum so this would require a separate enum -> not worth the effort.

@tobias-wilfert tobias-wilfert added this pull request to the merge queue May 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants