Skip to content

Commit a0e91bf

Browse files
romtsnclaude
andauthored
fix(proguard): Drop redundant line info validation for mapping files (#3192)
## Summary - Remove the `has_line_info()` check that rejected proguard mapping files without line information — our proguard mapper can handle these files fine - Remove `ProguardMappingError` enum and convert `TryFrom<ByteView>` to `From<ByteView>` - Update `DifFile::is_usable()` to always return `true` for proguard mappings, consistent with the change ## Test plan - [x] All 170 integration tests pass - [x] Clippy clean - [x] Removed obsolete `proguard-uuid-invalid-mapping.trycmd` test - [x] Updated `proguard-upload-no-upload` and `upload_proguard-no-upload` test snapshots 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent ef659de commit a0e91bf

9 files changed

Lines changed: 27 additions & 62 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Accept ProGuard mapping files without line information instead of rejecting them ([#3192](https://github.com/getsentry/sentry-cli/pull/3192)).
8+
59
### Experimental Feature 🧑‍🔬 (internal-only)
610

711
- Pipe snapshot sidecar metadata into upload as part of `sentry-cli build snapshots` command ([#3163](https://github.com/getsentry/sentry-cli/pull/3163)).

src/commands/proguard/upload.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
9595
// them all up.
9696
for path in &paths {
9797
match ByteView::open(path) {
98-
Ok(byteview) => match ProguardMapping::try_from(byteview) {
99-
Ok(mapping) => mappings.push(mapping),
100-
Err(e) => eprintln!("warning: ignoring proguard mapping '{path}': {e}"),
101-
},
98+
Ok(byteview) => mappings.push(ProguardMapping::from(byteview)),
10299
Err(ref err) if err.kind() == io::ErrorKind::NotFound => {
103100
eprintln!(
104101
"warning: proguard mapping '{path}' does not exist. This \

src/commands/proguard/uuid.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
2929

3030
let byteview = ByteView::open(path)
3131
.with_context(|| format!("failed to open proguard mapping '{path}'"))?;
32-
let mapping = ProguardMapping::try_from(byteview)
33-
.with_context(|| format!("failed to parse proguard mapping '{path}'"))?;
32+
let mapping = ProguardMapping::from(byteview);
3433

3534
println!("{}", mapping.uuid());
3635
Ok(())

src/utils/dif.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -380,24 +380,22 @@ impl<'a> DifFile<'a> {
380380
pub fn is_usable(&self) -> bool {
381381
match self {
382382
DifFile::Archive(_) => self.has_ids() && self.features().has_some(),
383-
DifFile::Proguard(pg) => pg.get().has_line_info(),
383+
DifFile::Proguard(..) => true,
384384
}
385385
}
386386

387387
pub fn get_problem(&self) -> Option<&'static str> {
388388
if self.is_usable() {
389-
None
390-
} else {
391-
Some(match self {
392-
DifFile::Archive(..) => {
393-
if !self.has_ids() {
394-
"missing debug identifier, likely stripped"
395-
} else {
396-
"missing debug or unwind information"
397-
}
398-
}
399-
DifFile::Proguard(..) => "missing line information",
400-
})
389+
return None;
390+
}
391+
392+
match self {
393+
DifFile::Archive(..) => Some(if !self.has_ids() {
394+
"missing debug identifier, likely stripped"
395+
} else {
396+
"missing debug or unwind information"
397+
}),
398+
DifFile::Proguard(..) => None,
401399
}
402400
}
403401

src/utils/proguard/mapping.rs

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,16 @@ use std::borrow::Cow;
22
use std::fmt::{Display, Formatter, Result as FmtResult};
33

44
use symbolic::common::{ByteView, DebugId};
5-
use thiserror::Error;
65
use uuid::Uuid;
76

87
use crate::utils::chunks::Assemblable;
98

10-
#[derive(Debug, Error)]
11-
pub enum ProguardMappingError {
12-
#[error("Proguard mapping does not contain line information")]
13-
MissingLineInfo,
14-
}
15-
169
pub struct ProguardMapping<'a> {
1710
bytes: ByteView<'a>,
1811
uuid: Uuid,
1912
}
2013

21-
impl<'a> ProguardMapping<'a> {
14+
impl ProguardMapping<'_> {
2215
/// Get the UUID of the mapping.
2316
pub fn uuid(&self) -> Uuid {
2417
self.uuid
@@ -29,31 +22,13 @@ impl<'a> ProguardMapping<'a> {
2922
pub fn force_uuid(&mut self, uuid: Uuid) {
3023
self.uuid = uuid;
3124
}
32-
33-
/// Create a new `ProguardMapping` from a `ByteView`.
34-
/// Not public because we want to ensure that the `ByteView` contains line
35-
/// information, and this method does not check for that. To create a
36-
/// `ProguardMapping` externally, use the `TryFrom<ByteView>` implementation.
37-
fn new(bytes: ByteView<'a>, uuid: Uuid) -> Self {
38-
Self { bytes, uuid }
39-
}
4025
}
4126

42-
impl<'a> TryFrom<ByteView<'a>> for ProguardMapping<'a> {
43-
type Error = ProguardMappingError;
44-
45-
/// Try to create a `ProguardMapping` from a `ByteView`.
46-
/// The method returns an error if the mapping does not contain
47-
/// line information.
48-
fn try_from(value: ByteView<'a>) -> Result<Self, Self::Error> {
27+
impl<'a> From<ByteView<'a>> for ProguardMapping<'a> {
28+
fn from(value: ByteView<'a>) -> Self {
4929
let mapping = ::proguard::ProguardMapping::new(&value);
50-
51-
if !mapping.has_line_info() {
52-
return Err(ProguardMappingError::MissingLineInfo);
53-
}
54-
5530
let uuid = mapping.uuid();
56-
Ok(ProguardMapping::new(value, uuid))
31+
Self { bytes: value, uuid }
5732
}
5833
}
5934

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
```
22
$ sentry-cli proguard upload tests/integration/_fixtures/proguard.txt --no-upload
33
? success
4-
warning: ignoring proguard mapping 'tests/integration/_fixtures/proguard.txt': Proguard mapping does not contain line information
54
> skipping upload.
65

76
```

tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```
2+
$ sentry-cli proguard uuid tests/integration/_fixtures/proguard.txt
3+
? success
4+
5db7294d-87fc-5726-a5c0-4a90679657a5
5+
6+
```
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
```
22
$ sentry-cli upload-proguard tests/integration/_fixtures/proguard.txt --no-upload
33
? success
4-
warning: ignoring proguard mapping 'tests/integration/_fixtures/proguard.txt': Proguard mapping does not contain line information
54
> skipping upload.
65

76
```

0 commit comments

Comments
 (0)