From bece2924c658d16c6584467e45a79722cf92df91 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 10 Jul 2026 11:48:35 +0200 Subject: [PATCH] ref(symbolic): Trivial breaking changes for v14 --- CHANGELOG.md | 8 ++++++++ symbolic-debuginfo/src/ppdb.rs | 2 +- symbolic-debuginfo/src/sourcebundle/mod.rs | 9 ++------ symbolic-ppdb/src/format/mod.rs | 24 ++++++---------------- symbolic-ppdb/tests/test_ppdb.rs | 2 +- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e519a07..761121111 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Unreleased + +**Breaking Changes** + +- `SourceBundleWriter::finish` now returns the underlying writer. ([#1016](https://github.com/getsentry/symbolic/pull/1016)) +- `FormatErrorKind::InvalidBlobFormat` is changed from `u32` to `i32`. ([#1016](https://github.com/getsentry/symbolic/pull/1016)) +- `EmbeddedSource::get_contents_bounded` now replaces `EmbeddedSource::get_contents`. ([#1016](https://github.com/getsentry/symbolic/pull/1016)) + ## 14.0.0-alpha.1 - No documented changes. diff --git a/symbolic-debuginfo/src/ppdb.rs b/symbolic-debuginfo/src/ppdb.rs index 553ceceb8..8498f6924 100644 --- a/symbolic-debuginfo/src/ppdb.rs +++ b/symbolic-debuginfo/src/ppdb.rs @@ -225,7 +225,7 @@ impl<'data> PortablePdbDebugSession<'data> { match sources.get(path) { None => Ok(None), Some(PPDBSource::Embedded(source)) => source - .get_contents_bounded(self.max_decompressed_embedded_source_size) + .get_contents(self.max_decompressed_embedded_source_size) .map(|bytes| { Some(SourceFileDescriptor::new_embedded( from_utf8_cow_lossy(&bytes), diff --git a/symbolic-debuginfo/src/sourcebundle/mod.rs b/symbolic-debuginfo/src/sourcebundle/mod.rs index 58e7fa52f..57526d34c 100644 --- a/symbolic-debuginfo/src/sourcebundle/mod.rs +++ b/symbolic-debuginfo/src/sourcebundle/mod.rs @@ -1514,18 +1514,13 @@ where } let is_empty = self.is_empty(); - let writer = self.do_finish()?; + let writer = self.finish()?; Ok((!is_empty, writer)) } /// Writes the manifest to the bundle and flushes the underlying file handle. - pub fn finish(self) -> Result<(), SourceBundleError> { - self.do_finish().map(drop) - } - - /// Writes the manifest to the bundle and flushes the underlying file handle. - fn do_finish(mut self) -> Result { + pub fn finish(mut self) -> Result { self.write_manifest()?; let writer = self .writer diff --git a/symbolic-ppdb/src/format/mod.rs b/symbolic-ppdb/src/format/mod.rs index aed617832..d9c473714 100644 --- a/symbolic-ppdb/src/format/mod.rs +++ b/symbolic-ppdb/src/format/mod.rs @@ -102,7 +102,7 @@ pub enum FormatErrorKind { InvalidCustomDebugInformationTag(u32), /// Tried to read contents of a blob in an unknown format. #[error("invalid blob format {0}")] - InvalidBlobFormat(u32), + InvalidBlobFormat(i32), /// Failed to parse Source Link JSON #[error("invalid source link JSON")] InvalidSourceLinkJson, @@ -478,16 +478,11 @@ impl<'data, 'object> EmbeddedSource<'data> { self.document.name.as_str() } - /// Reads the source file contents from the Portable PDB. - pub fn get_contents(&self) -> Result, FormatError> { - self.get_contents_bounded(None) - } - /// Reads the source file contents from the Portable PDB. /// /// If the contents are compressed, the decompressed size /// can be bounded with `max_decompressed_size`. - pub fn get_contents_bounded( + pub fn get_contents( &self, max_decompressed_size: Option, ) -> Result, FormatError> { @@ -501,26 +496,19 @@ impl<'data, 'object> EmbeddedSource<'data> { return Err(FormatErrorKind::InvalidBlobData.into()); } let (format_blob, data_blob) = self.blob.split_at(4); - let format = u32::from_ne_bytes(format_blob.try_into().unwrap()); - - // Per the above comment, the format is really an `i32`. - // None-negative values are currently valid, negative ones are reserved. - // We can't trivially change this to an `i32`, though, because of - // `FormatErrorKind::InvalidBlobFormat`, which expects a `u32`. - // Therefore, we manually bound the format here to the largest - // positive `i32`. - const MAX_VALID_FORMAT: u32 = i32::MAX as u32; + let format = i32::from_ne_bytes(format_blob.try_into().unwrap()); match format { 0 => Ok(Cow::Borrowed(data_blob)), - 1..=MAX_VALID_FORMAT => { + 1.. => { let size = format as usize; if max_decompressed_size.is_some_and(|max| size > max) { return Err(FormatErrorKind::EmbeddedSourceFileSizeExceeded(size).into()); } self.inflate_contents(size, data_blob) } - _ => Err(FormatErrorKind::InvalidBlobFormat(format).into()), + // Negative numbers are reserved for future formats. + ..0 => Err(FormatErrorKind::InvalidBlobFormat(format).into()), } } diff --git a/symbolic-ppdb/tests/test_ppdb.rs b/symbolic-ppdb/tests/test_ppdb.rs index d46d8afb7..b500dbdc8 100644 --- a/symbolic-ppdb/tests/test_ppdb.rs +++ b/symbolic-ppdb/tests/test_ppdb.rs @@ -43,7 +43,7 @@ fn test_embedded_sources() { } fn check_contents(item: &EmbeddedSource, length: usize, name: &str) { - let content = item.get_contents().unwrap(); + let content = item.get_contents(None).unwrap(); assert_eq!(content.len(), length); let expected = std::fs::read(format!("tests/fixtures/contents/{name}")).unwrap();