From ffc8502b46bba3ee61aa68a19a442d2f67998831 Mon Sep 17 00:00:00 2001 From: "Daniel Szoke (via Pi Coding Agent)" Date: Tue, 3 Mar 2026 15:53:42 +0000 Subject: [PATCH 1/2] feat(proguard): Add UUID command for mapping files (#3176) Add `sentry-cli proguard uuid ` to compute and print the UUID for a single ProGuard mapping file. This is the same UUID we use when uploading via `sentry-cli proguard upload` Stacked on #3175 Closes #3173 Closes [CLI-297](https://linear.app/getsentry/issue/CLI-297/expose-command-to-obtain-compute-uuid-for-proguard-mapping) --- CHANGELOG.md | 4 ++ src/commands/proguard/mod.rs | 2 + src/commands/proguard/uuid.rs | 37 +++++++++++++++++++ .../_cases/proguard/proguard-help.trycmd | 1 + .../_cases/proguard/proguard-uuid-help.trycmd | 36 ++++++++++++++++++ .../proguard-uuid-invalid-mapping.trycmd | 12 ++++++ .../proguard-uuid-missing-file.trycmd | 12 ++++++ .../proguard/proguard-uuid-success.trycmd | 6 +++ tests/integration/proguard/mod.rs | 1 + tests/integration/proguard/uuid.rs | 6 +++ 10 files changed, 117 insertions(+) create mode 100644 src/commands/proguard/uuid.rs create mode 100644 tests/integration/_cases/proguard/proguard-uuid-help.trycmd create mode 100644 tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd create mode 100644 tests/integration/_cases/proguard/proguard-uuid-missing-file.trycmd create mode 100644 tests/integration/_cases/proguard/proguard-uuid-success.trycmd create mode 100644 tests/integration/proguard/uuid.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index cdae4a1607..d767c61a44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### New Features + +- Added `sentry-cli proguard uuid ` to compute and print the UUID for a ProGuard mapping file ([#3176](https://github.com/getsentry/sentry-cli/pull/3176)). + ### Improvements - Moved `sentry-cli upload-proguard` to `sentry-cli proguard upload`, aligning the API with similar upload commands like `debug-files upload` and `sourcemaps upload` ([#3174](https://github.com/getsentry/sentry-cli/pull/3174)). `sentry-cli upload-proguard` remains supported as an alias, so no migration is required. diff --git a/src/commands/proguard/mod.rs b/src/commands/proguard/mod.rs index d7f3bad30a..d7e12f9199 100644 --- a/src/commands/proguard/mod.rs +++ b/src/commands/proguard/mod.rs @@ -2,10 +2,12 @@ use anyhow::Result; use clap::{ArgMatches, Command}; pub mod upload; +pub mod uuid; macro_rules! each_subcommand { ($mac:ident) => { $mac!(upload); + $mac!(uuid); }; } diff --git a/src/commands/proguard/uuid.rs b/src/commands/proguard/uuid.rs new file mode 100644 index 0000000000..188825afee --- /dev/null +++ b/src/commands/proguard/uuid.rs @@ -0,0 +1,37 @@ +use anyhow::{Context as _, Result}; +use clap::{Arg, ArgMatches, Command}; +use symbolic::common::ByteView; + +use crate::utils::proguard::ProguardMapping; + +pub fn make_command(command: Command) -> Command { + command + .about("Compute the UUID for a ProGuard mapping file.") + .long_about( + "Compute the UUID for a ProGuard mapping file.\n\n\ + This command computes and prints to stdout the UUID of the ProGuard \ + mapping at the specified path. This is the UUID that will be set by \ + the `proguard upload` command. The UUID is deterministicly computed \ + based on the file contents.", + ) + .arg( + Arg::new("path") + .value_name("PATH") + .help("The path to the mapping file.") + .required(true), + ) +} + +pub fn execute(matches: &ArgMatches) -> Result<()> { + let path = matches + .get_one::("path") + .expect("required argument"); + + 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}'"))?; + + println!("{}", mapping.uuid()); + Ok(()) +} diff --git a/tests/integration/_cases/proguard/proguard-help.trycmd b/tests/integration/_cases/proguard/proguard-help.trycmd index ffb4317cdc..66700a5671 100644 --- a/tests/integration/_cases/proguard/proguard-help.trycmd +++ b/tests/integration/_cases/proguard/proguard-help.trycmd @@ -7,6 +7,7 @@ Usage: sentry-cli[EXE] proguard [OPTIONS] Commands: upload Upload ProGuard mapping files to a project. + uuid Compute the UUID for a ProGuard mapping file. help Print this message or the help of the given subcommand(s) Options: diff --git a/tests/integration/_cases/proguard/proguard-uuid-help.trycmd b/tests/integration/_cases/proguard/proguard-uuid-help.trycmd new file mode 100644 index 0000000000..7815d142ea --- /dev/null +++ b/tests/integration/_cases/proguard/proguard-uuid-help.trycmd @@ -0,0 +1,36 @@ +``` +$ sentry-cli proguard uuid --help +? success +Compute the UUID for a ProGuard mapping file. + +This command computes and prints to stdout the UUID of the ProGuard mapping at the specified path. +This is the UUID that will be set by the `proguard upload` command. The UUID is deterministicly +computed based on the file contents. + +Usage: sentry-cli[EXE] proguard uuid [OPTIONS] + +Arguments: + + The path to the mapping file. + +Options: + --header + Custom headers that should be attached to all requests + in key:value format. + + --auth-token + Use the given Sentry auth token. + + --log-level + Set the log output verbosity. [possible values: trace, debug, info, warn, error] + + --quiet + Do not print any output while preserving correct exit code. This flag is currently + implemented only for selected subcommands. + + [aliases: --silent] + + -h, --help + Print help (see a summary with '-h') + +``` diff --git a/tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd b/tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd new file mode 100644 index 0000000000..18cb2afed4 --- /dev/null +++ b/tests/integration/_cases/proguard/proguard-uuid-invalid-mapping.trycmd @@ -0,0 +1,12 @@ +``` +$ 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-missing-file.trycmd b/tests/integration/_cases/proguard/proguard-uuid-missing-file.trycmd new file mode 100644 index 0000000000..64208d6c2a --- /dev/null +++ b/tests/integration/_cases/proguard/proguard-uuid-missing-file.trycmd @@ -0,0 +1,12 @@ +``` +$ sentry-cli proguard uuid tests/integration/_fixtures/proguard/upload/does-not-exist.txt +? failed +error: failed to open proguard mapping 'tests/integration/_fixtures/proguard/upload/does-not-exist.txt' + +Caused by: + [..] + +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-success.trycmd b/tests/integration/_cases/proguard/proguard-uuid-success.trycmd new file mode 100644 index 0000000000..10f2cabbdc --- /dev/null +++ b/tests/integration/_cases/proguard/proguard-uuid-success.trycmd @@ -0,0 +1,6 @@ +``` +$ sentry-cli proguard uuid tests/integration/_fixtures/proguard/upload/mapping.txt +? success +c038584d-c366-570c-ad1e-034fa0d194d7 + +``` diff --git a/tests/integration/proguard/mod.rs b/tests/integration/proguard/mod.rs index f8802ec1d8..b5bbd3e11a 100644 --- a/tests/integration/proguard/mod.rs +++ b/tests/integration/proguard/mod.rs @@ -1 +1,2 @@ mod upload; +mod uuid; diff --git a/tests/integration/proguard/uuid.rs b/tests/integration/proguard/uuid.rs new file mode 100644 index 0000000000..01d29b0495 --- /dev/null +++ b/tests/integration/proguard/uuid.rs @@ -0,0 +1,6 @@ +use crate::integration::TestManager; + +#[test] +fn command_proguard_uuid() { + TestManager::new().register_trycmd_test("proguard/proguard-uuid*.trycmd"); +} From 0e765fbe96cbd00188d2faf3a12ae8ccb97b12aa Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Tue, 3 Mar 2026 17:55:28 +0100 Subject: [PATCH 2/2] chore(proguard): Soft-deprecate the `proguard upload` `--uuid` flag (#3177) Using `--uuid` can cause unexpected behavior, if the same ProGuard mapping is uploaded with different UUIDs. Therefore, we now recommend using `proguard uuid` to obtain the UUID of a mapping before upload, as this eliminates the need to manually set a UUID. Stacked on #3176 Closes #3172 Closes [CLI-296](https://linear.app/getsentry/issue/CLI-296/proguard-upload-manually-specified-uuid-not-respected) --- src/commands/proguard/upload.rs | 14 ++++++++------ .../_cases/proguard/proguard-upload-help.trycmd | 6 ------ .../upload_proguard/upload_proguard-help.trycmd | 6 ------ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/commands/proguard/upload.rs b/src/commands/proguard/upload.rs index 4e623c7dc2..624b1b9fd4 100644 --- a/src/commands/proguard/upload.rs +++ b/src/commands/proguard/upload.rs @@ -59,13 +59,15 @@ pub fn make_command(command: Command) -> Command { .short('u') .value_name("UUID") .value_parser(Uuid::parse_str) + .hide(true) .help( - "Explicitly override the UUID of the mapping file with another one.{n}\ - This should be used with caution as it means that you can upload \ - multiple mapping files if you don't take care. This however can \ - be useful if you have a build process in which you need to know \ - the UUID of the proguard file before it was created. If you upload \ - a file with a forced UUID you can only upload a single proguard file.", + "[DEPRECATED] Manually override the UUID for the uploaded mapping.\n\ + We no longer recommend using this option. \ + If you use this option, you must use it consistently, and you must \ + ensure the UUID is generated deterministically based on the ProGuard \ + mapping. \n\ + If you need to know the UUID before upload, we recommend using the \ + `proguard uuid` command.", ), ) } diff --git a/tests/integration/_cases/proguard/proguard-upload-help.trycmd b/tests/integration/_cases/proguard/proguard-upload-help.trycmd index 9e5a586089..a61dcba74d 100644 --- a/tests/integration/_cases/proguard/proguard-upload-help.trycmd +++ b/tests/integration/_cases/proguard/proguard-upload-help.trycmd @@ -26,12 +26,6 @@ Options: flag is currently implemented only for selected subcommands. [aliases: --silent] --require-one Requires at least one file to upload or the command will error. - -u, --uuid Explicitly override the UUID of the mapping file with another one. - This should be used with caution as it means that you can upload - multiple mapping files if you don't take care. This however can be - useful if you have a build process in which you need to know the - UUID of the proguard file before it was created. If you upload a - file with a forced UUID you can only upload a single proguard file. -h, --help Print help ``` diff --git a/tests/integration/_cases/upload_proguard/upload_proguard-help.trycmd b/tests/integration/_cases/upload_proguard/upload_proguard-help.trycmd index 1a04f16588..990b4aa1cd 100644 --- a/tests/integration/_cases/upload_proguard/upload_proguard-help.trycmd +++ b/tests/integration/_cases/upload_proguard/upload_proguard-help.trycmd @@ -26,12 +26,6 @@ Options: flag is currently implemented only for selected subcommands. [aliases: --silent] --require-one Requires at least one file to upload or the command will error. - -u, --uuid Explicitly override the UUID of the mapping file with another one. - This should be used with caution as it means that you can upload - multiple mapping files if you don't take care. This however can be - useful if you have a build process in which you need to know the - UUID of the proguard file before it was created. If you upload a - file with a forced UUID you can only upload a single proguard file. -h, --help Print help ```