Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
5 changes: 1 addition & 4 deletions src/commands/proguard/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 1 addition & 2 deletions src/commands/proguard/uuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
22 changes: 8 additions & 14 deletions src/utils/dif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,24 +380,18 @@ 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(),
_ => true,
Comment thread
romtsn marked this conversation as resolved.
Outdated
}
}

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",
})
match self {
DifFile::Archive(..) if !self.is_usable() => Some(if !self.has_ids() {
"missing debug identifier, likely stripped"
} else {
"missing debug or unwind information"
}),
_ => None,
Comment thread
romtsn marked this conversation as resolved.
Outdated
}
}

Expand Down
33 changes: 4 additions & 29 deletions src/utils/proguard/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<ByteView>` implementation.
fn new(bytes: ByteView<'a>, uuid: Uuid) -> Self {
Self { bytes, uuid }
}
}

impl<'a> TryFrom<ByteView<'a>> 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<Self, Self::Error> {
impl<'a> From<ByteView<'a>> 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 }
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.

```
Comment thread
romtsn marked this conversation as resolved.
Outdated

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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.

```