Skip to content

Commit 8a1bb73

Browse files
ref(bundle-jvm): No more API calls in bundle-jvm (#2926)
### Description We don't need to be calling the chunk upload endpoint from `bundle-jvm` following the refactors in previous PRs ### Issues - Resolves #2927 - Resolves [CLI-220](https://linear.app/getsentry/issue/CLI-220/dont-call-chunk-upload-for-bundle-jvm)
1 parent 0c834b2 commit 8a1bb73

File tree

4 files changed

+42
-44
lines changed

4 files changed

+42
-44
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
### Improvements
6+
7+
- The `sentry-cli debug-files bundle-jvm` no longer makes any HTTP requests to Sentry, meaning auth tokenms are no longer needed, and the command can be run offline ([#2926](https://github.com/getsentry/sentry-cli/pull/2926)).
8+
39
## 2.58.0
410

511
### New Features

src/commands/debug_files/bundle_jvm.rs

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#![expect(clippy::unwrap_used, reason = "contains legacy code which uses unwrap")]
22

3-
use crate::api::Api;
43
use crate::config::Config;
5-
use crate::constants::DEFAULT_MAX_WAIT;
64
use crate::utils::args::ArgExt as _;
75
use crate::utils::file_search::ReleaseFileSearch;
8-
use crate::utils::file_upload::{FileUpload, SourceFile, UploadContext};
6+
use crate::utils::file_upload::SourceFile;
97
use crate::utils::fs::path_as_url;
8+
use crate::utils::source_bundle::{self, BundleContext};
109
use anyhow::{bail, Context as _, Result};
1110
use clap::{Arg, ArgMatches, Command};
1211
use sentry::types::DebugId;
@@ -54,19 +53,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
5453
let config = Config::current();
5554
let org = config.get_org(matches)?;
5655
let project = config.get_project(matches).ok();
57-
let api = Api::current();
58-
let chunk_upload_options = api.authenticated()?.get_chunk_upload_options(&org)?;
5956

60-
let context = &UploadContext {
61-
org: &org,
62-
projects: project.as_slice().try_into().ok(),
63-
release: None,
64-
dist: None,
65-
note: None,
66-
wait: true,
67-
max_wait: DEFAULT_MAX_WAIT,
68-
chunk_upload_options: chunk_upload_options.as_ref(),
69-
};
57+
let context = BundleContext::new(&org).with_projects(project.as_slice());
7058
let path = matches.get_one::<PathBuf>("path").unwrap();
7159
let output_path = matches.get_one::<PathBuf>("output").unwrap();
7260
let debug_id = matches.get_one::<DebugId>("debug_id").unwrap();
@@ -88,30 +76,23 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
8876
}
8977

9078
let sources = ReleaseFileSearch::new(path.to_path_buf()).collect_files()?;
91-
let files = sources
92-
.iter()
93-
.map(|source| {
94-
let local_path = source.path.strip_prefix(&source.base_path).unwrap();
95-
let local_path_jvm_ext = local_path.with_extension("jvm");
96-
let url = format!("~/{}", path_as_url(&local_path_jvm_ext));
97-
(
98-
url.clone(),
99-
SourceFile {
100-
url,
101-
path: source.path.clone(),
102-
contents: Arc::new(source.contents.clone()),
103-
ty: SourceFileType::Source,
104-
headers: BTreeMap::new(),
105-
messages: vec![],
106-
already_uploaded: false,
107-
},
108-
)
109-
})
110-
.collect();
79+
let files = sources.iter().map(|source| {
80+
let local_path = source.path.strip_prefix(&source.base_path).unwrap();
81+
let local_path_jvm_ext = local_path.with_extension("jvm");
82+
let url = format!("~/{}", path_as_url(&local_path_jvm_ext));
11183

112-
let tempfile = FileUpload::new(context)
113-
.files(&files)
114-
.build_jvm_bundle(Some(*debug_id))
84+
SourceFile {
85+
url,
86+
path: source.path.clone(),
87+
contents: Arc::new(source.contents.clone()),
88+
ty: SourceFileType::Source,
89+
headers: BTreeMap::new(),
90+
messages: vec![],
91+
already_uploaded: false,
92+
}
93+
});
94+
95+
let tempfile = source_bundle::build(context, files, Some(*debug_id))
11596
.context("Unable to create source bundle")?;
11697

11798
fs::copy(tempfile.path(), &out).context("Unable to write source bundle")?;

src/utils/file_upload.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use console::style;
1212
use parking_lot::RwLock;
1313
use rayon::prelude::*;
1414
use rayon::ThreadPoolBuilder;
15-
use sentry::types::DebugId;
1615
use sha1_smol::Digest;
1716
use symbolic::common::ByteView;
1817
use symbolic::debuginfo::js;
@@ -23,7 +22,7 @@ use crate::api::NewRelease;
2322
use crate::api::{Api, ChunkServerOptions, ChunkUploadCapability};
2423
use crate::constants::DEFAULT_MAX_WAIT;
2524
use crate::utils::chunks::{upload_chunks, Chunk, ASSEMBLE_POLL_INTERVAL};
26-
use crate::utils::fs::{get_sha1_checksums, TempFile};
25+
use crate::utils::fs::get_sha1_checksums;
2726
use crate::utils::non_empty::NonEmptySlice;
2827
use crate::utils::progress::{ProgressBar, ProgressBarMode, ProgressStyle};
2928
use crate::utils::source_bundle;
@@ -409,10 +408,6 @@ impl<'a> FileUpload<'a> {
409408
#[expect(deprecated, reason = "fallback to legacy upload")]
410409
upload_files_parallel(legacy_context, &self.files, concurrency)
411410
}
412-
413-
pub fn build_jvm_bundle(&self, debug_id: Option<DebugId>) -> Result<TempFile> {
414-
source_bundle::build(self.context, self.files.values(), debug_id)
415-
}
416411
}
417412

418413
#[deprecated = "this non-chunked upload mechanism is deprecated in favor of upload_files_chunked"]

src/utils/source_bundle.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ pub struct BundleContext<'a> {
2323
dist: Option<&'a str>,
2424
}
2525

26+
impl<'a> BundleContext<'a> {
27+
/// Make a new context with the given organization; other fields
28+
/// are left to None.
29+
pub fn new(org: &'a str) -> Self {
30+
Self {
31+
org,
32+
..Default::default()
33+
}
34+
}
35+
36+
pub fn with_projects(mut self, projects: &'a [String]) -> Self {
37+
self.projects = projects.try_into().ok();
38+
self
39+
}
40+
}
41+
2642
impl<'a> From<&'a UploadContext<'a>> for BundleContext<'a> {
2743
fn from(context: &'a UploadContext<'a>) -> Self {
2844
Self {

0 commit comments

Comments
 (0)