diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ce3b4f655..982b5375fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fixes + +- Accept ProGuard mapping files without line information instead of rejecting them ([#3192](https://github.com/getsentry/sentry-cli/pull/3192)). + ### Experimental Feature 🧑‍🔬 (internal-only) - Pipe snapshot sidecar metadata into upload as part of `sentry-cli build snapshots` command ([#3163](https://github.com/getsentry/sentry-cli/pull/3163)). diff --git a/src/commands/proguard/upload.rs b/src/commands/proguard/upload.rs index 624b1b9fd4..c1831d32b2 100644 --- a/src/commands/proguard/upload.rs +++ b/src/commands/proguard/upload.rs @@ -95,10 +95,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { // them all up. for path in &paths { match ByteView::open(path) { - Ok(byteview) => match ProguardMapping::try_from(byteview) { - Ok(mapping) => mappings.push(mapping), - Err(e) => eprintln!("warning: ignoring proguard mapping '{path}': {e}"), - }, + Ok(byteview) => mappings.push(ProguardMapping::from(byteview)), Err(ref err) if err.kind() == io::ErrorKind::NotFound => { eprintln!( "warning: proguard mapping '{path}' does not exist. This \ diff --git a/src/commands/proguard/uuid.rs b/src/commands/proguard/uuid.rs index 188825afee..e0a4b3034f 100644 --- a/src/commands/proguard/uuid.rs +++ b/src/commands/proguard/uuid.rs @@ -29,8 +29,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { let byteview = ByteView::open(path) .with_context(|| format!("failed to open proguard mapping '{path}'"))?; - let mapping = ProguardMapping::try_from(byteview) - .with_context(|| format!("failed to parse proguard mapping '{path}'"))?; + let mapping = ProguardMapping::from(byteview); println!("{}", mapping.uuid()); Ok(()) diff --git a/src/utils/dif.rs b/src/utils/dif.rs index cf510dad91..321244f378 100644 --- a/src/utils/dif.rs +++ b/src/utils/dif.rs @@ -380,24 +380,22 @@ impl<'a> DifFile<'a> { pub fn is_usable(&self) -> bool { match self { DifFile::Archive(_) => self.has_ids() && self.features().has_some(), - DifFile::Proguard(pg) => pg.get().has_line_info(), + DifFile::Proguard(..) => true, } } pub fn get_problem(&self) -> Option<&'static str> { if self.is_usable() { - None - } else { - Some(match self { - DifFile::Archive(..) => { - if !self.has_ids() { - "missing debug identifier, likely stripped" - } else { - "missing debug or unwind information" - } - } - DifFile::Proguard(..) => "missing line information", - }) + return None; + } + + match self { + DifFile::Archive(..) => Some(if !self.has_ids() { + "missing debug identifier, likely stripped" + } else { + "missing debug or unwind information" + }), + DifFile::Proguard(..) => None, } } diff --git a/src/utils/proguard/mapping.rs b/src/utils/proguard/mapping.rs index 40117cad5e..51d021d65d 100644 --- a/src/utils/proguard/mapping.rs +++ b/src/utils/proguard/mapping.rs @@ -2,23 +2,16 @@ use std::borrow::Cow; use std::fmt::{Display, Formatter, Result as FmtResult}; use symbolic::common::{ByteView, DebugId}; -use thiserror::Error; use uuid::Uuid; use crate::utils::chunks::Assemblable; -#[derive(Debug, Error)] -pub enum ProguardMappingError { - #[error("Proguard mapping does not contain line information")] - MissingLineInfo, -} - pub struct ProguardMapping<'a> { bytes: ByteView<'a>, uuid: Uuid, } -impl<'a> ProguardMapping<'a> { +impl ProguardMapping<'_> { /// Get the UUID of the mapping. pub fn uuid(&self) -> Uuid { self.uuid @@ -29,31 +22,13 @@ impl<'a> ProguardMapping<'a> { pub fn force_uuid(&mut self, uuid: Uuid) { self.uuid = uuid; } - - /// Create a new `ProguardMapping` from a `ByteView`. - /// Not public because we want to ensure that the `ByteView` contains line - /// information, and this method does not check for that. To create a - /// `ProguardMapping` externally, use the `TryFrom` implementation. - fn new(bytes: ByteView<'a>, uuid: Uuid) -> Self { - Self { bytes, uuid } - } } -impl<'a> TryFrom> for ProguardMapping<'a> { - type Error = ProguardMappingError; - - /// Try to create a `ProguardMapping` from a `ByteView`. - /// The method returns an error if the mapping does not contain - /// line information. - fn try_from(value: ByteView<'a>) -> Result { +impl<'a> From> for ProguardMapping<'a> { + fn from(value: ByteView<'a>) -> Self { let mapping = ::proguard::ProguardMapping::new(&value); - - if !mapping.has_line_info() { - return Err(ProguardMappingError::MissingLineInfo); - } - let uuid = mapping.uuid(); - Ok(ProguardMapping::new(value, uuid)) + Self { bytes: value, uuid } } } diff --git a/tests/integration/_cases/proguard/proguard-upload-no-upload.trycmd b/tests/integration/_cases/proguard/proguard-upload-no-upload.trycmd index b2c1e0a483..a601ef21bc 100644 --- a/tests/integration/_cases/proguard/proguard-upload-no-upload.trycmd +++ b/tests/integration/_cases/proguard/proguard-upload-no-upload.trycmd @@ -1,7 +1,6 @@ ``` $ sentry-cli proguard upload tests/integration/_fixtures/proguard.txt --no-upload ? success -warning: ignoring proguard mapping 'tests/integration/_fixtures/proguard.txt': Proguard mapping does not contain line information > skipping upload. ``` diff --git a/tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd b/tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd deleted file mode 100644 index 18cb2afed4..0000000000 --- a/tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd +++ /dev/null @@ -1,12 +0,0 @@ -``` -$ sentry-cli proguard uuid tests/integration/_fixtures/proguard.txt -? failed -error: failed to parse proguard mapping 'tests/integration/_fixtures/proguard.txt' - -Caused by: - Proguard mapping does not contain line information - -Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output. -Please attach the full debug log to all bug reports. - -``` diff --git a/tests/integration/_cases/proguard/proguard-uuid-no-line-info.trycmd b/tests/integration/_cases/proguard/proguard-uuid-no-line-info.trycmd new file mode 100644 index 0000000000..e0caea5b65 --- /dev/null +++ b/tests/integration/_cases/proguard/proguard-uuid-no-line-info.trycmd @@ -0,0 +1,6 @@ +``` +$ sentry-cli proguard uuid tests/integration/_fixtures/proguard.txt +? success +5db7294d-87fc-5726-a5c0-4a90679657a5 + +``` diff --git a/tests/integration/_cases/upload_proguard/upload_proguard-no-upload.trycmd b/tests/integration/_cases/upload_proguard/upload_proguard-no-upload.trycmd index cb30fac691..51b33b8feb 100644 --- a/tests/integration/_cases/upload_proguard/upload_proguard-no-upload.trycmd +++ b/tests/integration/_cases/upload_proguard/upload_proguard-no-upload.trycmd @@ -1,7 +1,6 @@ ``` $ sentry-cli upload-proguard tests/integration/_fixtures/proguard.txt --no-upload ? success -warning: ignoring proguard mapping 'tests/integration/_fixtures/proguard.txt': Proguard mapping does not contain line information > skipping upload. ```