diff --git a/src/api/data_types/chunking/mobile_app.rs b/src/api/data_types/chunking/mobile_app.rs index 6223e78c30..72c8339481 100644 --- a/src/api/data_types/chunking/mobile_app.rs +++ b/src/api/data_types/chunking/mobile_app.rs @@ -20,5 +20,5 @@ pub struct AssembleMobileAppResponse { pub state: ChunkedFileState, pub missing_chunks: Vec, pub detail: Option, - pub artifact_id: Option, + pub artifact_url: Option, } diff --git a/src/commands/mobile_app/upload.rs b/src/commands/mobile_app/upload.rs index 55ccad7c64..42cd7b3e06 100644 --- a/src/commands/mobile_app/upload.rs +++ b/src/commands/mobile_app/upload.rs @@ -117,9 +117,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { let config = Config::current(); let (org, project) = config.get_org_and_project(matches)?; - let base_url = config.get_base_url()?; - let mut uploaded_paths_and_ids = vec![]; + let mut uploaded_paths_and_urls = vec![]; let mut errored_paths_and_reasons = vec![]; for (path, zip) in normalized_zips { info!("Uploading file: {}", path.display()); @@ -132,9 +131,9 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { sha.as_deref(), build_configuration, ) { - Ok(artifact_id) => { + Ok(artifact_url) => { info!("Successfully uploaded file: {}", path.display()); - uploaded_paths_and_ids.push((path.to_path_buf(), artifact_id)); + uploaded_paths_and_urls.push((path.to_path_buf(), artifact_url)); } Err(e) => { debug!("Failed to upload file at path {}: {}", path.display(), e); @@ -158,22 +157,21 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { } } - if uploaded_paths_and_ids.is_empty() { + if uploaded_paths_and_urls.is_empty() { bail!("Failed to upload any files"); } else { println!( "Successfully uploaded {} file{} to Sentry", - uploaded_paths_and_ids.len(), - if uploaded_paths_and_ids.len() == 1 { + uploaded_paths_and_urls.len(), + if uploaded_paths_and_urls.len() == 1 { "" } else { "s" } ); - if uploaded_paths_and_ids.len() < 3 { - for (path, artifact_id) in &uploaded_paths_and_ids { - let url = format!("{base_url}/{org}/preprod/{project}/{artifact_id}"); - println!(" - {} ({url})", path.display()); + if uploaded_paths_and_urls.len() < 3 { + for (path, artifact_url) in &uploaded_paths_and_urls { + println!(" - {} {artifact_url}", path.display()); } } } @@ -283,7 +281,7 @@ fn handle_directory(path: &Path) -> Result { normalize_directory(path, temp_dir.path()) } -/// Returns artifact id if upload was successful. +/// Returns artifact url if upload was successful. fn upload_file( api: &AuthenticatedApi, bytes: &[u8], @@ -336,15 +334,16 @@ fn upload_file( // In the normal case we go through this loop exactly twice: // 1. state=not_found // server tells us the we need to send every chunk and we do so - // 2. artifact_id set so we're done (likely state=created) + // 2. artifact_url set so we're done (likely state=created) // // In the case where all the chunks are already on the server we go // through only once: - // 1. state=ok, artifact_id set + // 1. state=created, artifact_url set // // In the case where something went wrong (which could be on either // iteration of the loop) we get: - // n. state=err, artifact_id unset + // n. state=error, artifact_url unset + let result = loop { let response = api.assemble_mobile_app(org, project, checksum, &checksums, sha, build_configuration)?; @@ -357,7 +356,6 @@ fn upload_file( ); upload_chunks(&chunks, &chunk_upload_options, upload_progress_style)?; } - // state.is_err() is not the same as this since it also returns // true for ChunkedFileState::NotFound. if response.state == ChunkedFileState::Error { @@ -365,8 +363,8 @@ fn upload_file( bail!("Failed to process uploaded files: {}", message); } - if let Some(artifact_id) = response.artifact_id { - break Ok(artifact_id); + if let Some(artifact_url) = response.artifact_url { + break Ok(artifact_url); } if response.state.is_finished() { diff --git a/tests/integration/mobile_app/upload.rs b/tests/integration/mobile_app/upload.rs index 613be3b42d..e6f1508bed 100644 --- a/tests/integration/mobile_app/upload.rs +++ b/tests/integration/mobile_app/upload.rs @@ -86,7 +86,7 @@ fn command_mobile_app_upload_apk_all_uploaded() { "POST", "/api/0/projects/wat-org/wat-project/files/preprodartifacts/assemble/", ) - .with_response_body(r#"{"state":"ok","missingChunks":[],"artifactId":"42"}"#), + .with_response_body(r#"{"state":"ok","missingChunks":[],"artifactUrl":"https://sentry.io/wat-org/preprod/wat-project/42"}"#), ) .register_trycmd_test("mobile_app/mobile_app-upload-apk-all-uploaded.trycmd") .with_default_token(); @@ -170,7 +170,7 @@ fn command_mobile_app_upload_apk_chunked() { r#"{ "state": "ok", "missingChunks": [], - "artifactId": "42" + "artifactUrl": "http://sentry.io/wat-org/preprod/wat-project/42" }"# } .into() @@ -225,7 +225,7 @@ fn command_mobile_app_upload_ipa_chunked() { r#"{ "state": "ok", "missingChunks": [], - "artifactId": "some-text-id" + "artifactUrl": "http://sentry.io/wat-org/preprod/wat-project/some-text-id" }"# } .into()