Skip to content

Commit 4330fcb

Browse files
feat(proguard): Use chunk uploading by default
Enable chunk uploads for Proguard files. This upload method avoids 502 errors when uploading large Proguard files, and enables interrupted uploads to be resumed.
1 parent db5e5e4 commit 4330fcb

File tree

4 files changed

+19
-25
lines changed

4 files changed

+19
-25
lines changed

src/api/data_types/chunking/upload/capability.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pub enum ChunkUploadCapability {
3333
/// Upload of preprod artifacts
3434
PreprodArtifacts,
3535

36+
/// Upload of ProGuard mappings
37+
Proguard,
38+
3639
/// Any other unsupported capability (ignored)
3740
Unknown,
3841
}
@@ -53,6 +56,7 @@ impl<'de> Deserialize<'de> for ChunkUploadCapability {
5356
"bcsymbolmaps" => ChunkUploadCapability::BcSymbolmap,
5457
"il2cpp" => ChunkUploadCapability::Il2Cpp,
5558
"preprod_artifacts" => ChunkUploadCapability::PreprodArtifacts,
59+
"proguard" => ChunkUploadCapability::Proguard,
5660
_ => ChunkUploadCapability::Unknown,
5761
})
5862
}

src/commands/upload_proguard.rs

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::env;
21
use std::io;
32

43
use anyhow::{bail, Error, Result};
@@ -10,6 +9,7 @@ use uuid::Uuid;
109

1110
use crate::api::Api;
1211
use crate::api::AssociateProguard;
12+
use crate::api::ChunkUploadCapability;
1313
use crate::config::Config;
1414
use crate::utils::android::dump_proguard_uuids_as_properties;
1515
use crate::utils::args::ArgExt as _;
@@ -19,8 +19,6 @@ use crate::utils::proguard::ProguardMapping;
1919
use crate::utils::system::QuietExit;
2020
use crate::utils::ui::{copy_with_progress, make_byte_progress_bar};
2121

22-
const CHUNK_UPLOAD_ENV_VAR: &str = "SENTRY_EXPERIMENTAL_PROGUARD_CHUNK_UPLOAD";
23-
2422
pub fn make_command(command: Command) -> Command {
2523
command
2624
.about("Upload ProGuard mapping files to a project.")
@@ -187,29 +185,22 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
187185
let authenticated_api;
188186
let (org, project);
189187

190-
if env::var(CHUNK_UPLOAD_ENV_VAR) == Ok("1".into()) {
191-
log::warn!(
192-
"EXPERIMENTAL FEATURE: Uploading proguard mappings using chunked uploading. \
193-
Some functionality may be unavailable when using chunked uploading. Please unset \
194-
the {CHUNK_UPLOAD_ENV_VAR} variable if you encounter any \
195-
problems."
196-
);
188+
let chunk_upload_options = if matches.get_flag("no_upload") {
189+
None
190+
} else {
191+
let authenticated_api = api.authenticated()?;
192+
let org = config.get_org(matches)?;
193+
authenticated_api
194+
.get_chunk_upload_options(&org)
195+
.ok()
196+
.flatten()
197+
};
197198

199+
if let Some(chunk_upload_options) =
200+
chunk_upload_options.filter(|options| options.supports(ChunkUploadCapability::Proguard))
201+
{
198202
authenticated_api = api.authenticated()?;
199203
(org, project) = config.get_org_and_project(matches)?;
200-
201-
let chunk_upload_options = authenticated_api
202-
.get_chunk_upload_options(&org)
203-
.map_err(|e| anyhow::anyhow!(e))
204-
.and_then(|options| {
205-
options.ok_or_else(|| {
206-
anyhow::anyhow!(
207-
"server does not support chunked uploading. unset \
208-
{CHUNK_UPLOAD_ENV_VAR} to continue."
209-
)
210-
})
211-
})?;
212-
213204
proguard::chunk_upload(&mappings, chunk_upload_options, &org, &project)?;
214205
} else {
215206
if mappings.is_empty() && matches.get_flag("require_one") {

tests/integration/_responses/debug_files/get-chunk-upload.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"concurrency": 8,
88
"hashAlgorithm": "sha1",
99
"compression": ["gzip"],
10-
"accept": ["debug_files", "release_files", "pdbs", "portablepdbs", "sources", "bcsymbolmaps"]
10+
"accept": ["debug_files", "release_files", "pdbs", "portablepdbs", "sources", "bcsymbolmaps", "proguard"]
1111
}

tests/integration/upload_proguard.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ fn chunk_upload_already_there() {
7272
"tests/integration/_fixtures/upload_proguard/mapping.txt",
7373
])
7474
.with_default_token()
75-
.env("SENTRY_EXPERIMENTAL_PROGUARD_CHUNK_UPLOAD", "1")
7675
.run_and_assert(AssertCommand::Success)
7776
}
7877

0 commit comments

Comments
 (0)