Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/api/data_types/chunking/dif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ pub struct ChunkedDifResponse {
#[serde(transparent)]
pub struct AssembleDifsRequest<'a>(HashMap<Digest, ChunkedDifRequest<'a>>);

impl AssembleDifsRequest<'_> {
/// Strips the debug_id from all requests in the request. We need
/// to strip the debug_ids whenever the server does not support chunked
/// uploading of PDBs, to maintain backwards compatibility. The
/// calling code is responsible for calling this function when needed.
///
/// See: https://github.com/getsentry/sentry-cli/issues/980
/// See: https://github.com/getsentry/sentry-cli/issues/1056
pub fn strip_debug_ids(&mut self) {
for r in self.0.values_mut() {
r.debug_id = None;
}
}
}

impl<'a, T> FromIterator<T> for AssembleDifsRequest<'a>
where
T: Into<ChunkedDifRequest<'a>>,
Expand Down
24 changes: 0 additions & 24 deletions src/api/data_types/chunking/upload/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ use serde::{Deserialize, Deserializer};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ChunkUploadCapability {
/// Chunked upload of debug files
DebugFiles,

/// Chunked upload of release files
ReleaseFiles,

Expand All @@ -15,21 +12,6 @@ pub enum ChunkUploadCapability {
/// upload.
ArtifactBundlesV2,

/// Upload of PDBs and debug id overrides
Pdbs,

/// Upload of Portable PDBs
PortablePdbs,

/// Uploads of source archives
Sources,

/// Upload of BCSymbolMap and PList auxiliary DIFs
BcSymbolmap,

/// Upload of il2cpp line mappings
Il2Cpp,

/// Upload of Dart symbol maps
DartSymbolMap,

Expand All @@ -49,15 +31,9 @@ impl<'de> Deserialize<'de> for ChunkUploadCapability {
D: Deserializer<'de>,
{
Ok(match String::deserialize(deserializer)?.as_str() {
"debug_files" => ChunkUploadCapability::DebugFiles,
"release_files" => ChunkUploadCapability::ReleaseFiles,
"artifact_bundles" => ChunkUploadCapability::ArtifactBundles,
"artifact_bundles_v2" => ChunkUploadCapability::ArtifactBundlesV2,
"pdbs" => ChunkUploadCapability::Pdbs,
"portablepdbs" => ChunkUploadCapability::PortablePdbs,
"sources" => ChunkUploadCapability::Sources,
"bcsymbolmaps" => ChunkUploadCapability::BcSymbolmap,
"il2cpp" => ChunkUploadCapability::Il2Cpp,
"dartsymbolmap" => ChunkUploadCapability::DartSymbolMap,
"preprod_artifacts" => ChunkUploadCapability::PreprodArtifacts,
"proguard" => ChunkUploadCapability::Proguard,
Expand Down
16 changes: 1 addition & 15 deletions src/api/data_types/chunking/upload/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct ChunkServerOptions {
pub concurrency: u8,
#[serde(default)]
pub compression: Vec<ChunkCompression>,
#[serde(default = "default_chunk_upload_accept")]
#[serde(default)]
pub accept: Vec<ChunkUploadCapability>,
}

Expand All @@ -32,18 +32,4 @@ impl ChunkServerOptions {
pub fn supports(&self, capability: ChunkUploadCapability) -> bool {
self.accept.contains(&capability)
}

/// Determines whether we need to strip debug_ids from the requests. We need
/// to strip the debug_ids whenever the server does not support chunked
/// uploading of PDBs, to maintain backwards compatibility.
///
/// See: https://github.com/getsentry/sentry-cli/issues/980
/// See: https://github.com/getsentry/sentry-cli/issues/1056
pub fn should_strip_debug_ids(&self) -> bool {
!self.supports(ChunkUploadCapability::DebugFiles)
}
}

fn default_chunk_upload_accept() -> Vec<ChunkUploadCapability> {
vec![ChunkUploadCapability::DebugFiles]
}
4 changes: 0 additions & 4 deletions src/utils/chunks/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ impl<'a> ChunkOptions<'a> {
self
}

pub fn should_strip_debug_ids(&self) -> bool {
self.server_options.should_strip_debug_ids()
}

pub fn org(&self) -> &str {
self.org
}
Expand Down
11 changes: 2 additions & 9 deletions src/utils/chunks/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,7 @@ where
T: AsRef<[u8]> + Assemblable,
{
let api = Api::current();
let mut request: AssembleDifsRequest<'_> = objects.iter().collect();

if options.should_strip_debug_ids() {
request.strip_debug_ids();
}
let request: AssembleDifsRequest<'_> = objects.iter().collect();

let response =
api.authenticated()?
Expand Down Expand Up @@ -188,10 +184,7 @@ where

let assemble_start = Instant::now();

let mut request: AssembleDifsRequest<'_> = chunked_objects.iter().copied().collect();
if options.should_strip_debug_ids() {
request.strip_debug_ids();
}
let request: AssembleDifsRequest<'_> = chunked_objects.iter().copied().collect();

let response = loop {
let response =
Expand Down
77 changes: 1 addition & 76 deletions src/utils/dif_upload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use zip::result::ZipError;
use zip::ZipArchive;

use self::error::ValidationError;
use crate::api::{Api, ChunkServerOptions, ChunkUploadCapability};
use crate::api::{Api, ChunkServerOptions};
use crate::config::Config;
use crate::constants::{DEFAULT_MAX_DIF_SIZE, DEFAULT_MAX_WAIT};
use crate::utils::chunks;
Expand Down Expand Up @@ -1267,14 +1267,9 @@ pub struct DifUpload<'a> {
zips_allowed: bool,
max_file_size: u64,
max_wait: Duration,
pdbs_allowed: bool,
portablepdbs_allowed: bool,
sources_allowed: bool,
include_sources: bool,
bcsymbolmaps_allowed: bool,
wait: bool,
upload_il2cpp_mappings: bool,
il2cpp_mappings_allowed: bool,
no_upload: bool,
}

Expand Down Expand Up @@ -1308,14 +1303,9 @@ impl<'a> DifUpload<'a> {
zips_allowed: true,
max_file_size: DEFAULT_MAX_DIF_SIZE,
max_wait: DEFAULT_MAX_WAIT,
pdbs_allowed: false,
portablepdbs_allowed: false,
sources_allowed: false,
include_sources: false,
bcsymbolmaps_allowed: false,
wait: false,
upload_il2cpp_mappings: false,
il2cpp_mappings_allowed: false,
no_upload: false,
}
}
Expand Down Expand Up @@ -1465,69 +1455,9 @@ impl<'a> DifUpload<'a> {
.min(Duration::from_secs(chunk_options.max_wait));
}

self.pdbs_allowed = chunk_options.supports(ChunkUploadCapability::Pdbs);
self.portablepdbs_allowed = chunk_options.supports(ChunkUploadCapability::PortablePdbs);
self.sources_allowed = chunk_options.supports(ChunkUploadCapability::Sources);
self.bcsymbolmaps_allowed = chunk_options.supports(ChunkUploadCapability::BcSymbolmap);
self.il2cpp_mappings_allowed = chunk_options.supports(ChunkUploadCapability::Il2Cpp);

if !chunk_options.supports(ChunkUploadCapability::DebugFiles) {
anyhow::bail!(
"Your Sentry server does not support chunked uploads for debug files. Please upgrade \
your Sentry server, or if you cannot upgrade your server, downgrade your Sentry \
CLI version to 2.x."
);
}

self.validate_capabilities();
upload_difs_chunked(self, chunk_options)
}

/// Validate that the server supports all requested capabilities.
fn validate_capabilities(&mut self) {
// Checks whether source bundles are *explicitly* requested on the command line.
if (self
.formats
.contains(&DifFormat::Object(FileFormat::SourceBundle))
|| self.include_sources)
&& !self.sources_allowed
{
warn!("Source uploads are not supported by the configured Sentry server");
self.include_sources = false;
}

// Checks whether PDBs or PEs were *explicitly* requested on the command line.
if (self.formats.contains(&DifFormat::Object(FileFormat::Pdb))
|| self.formats.contains(&DifFormat::Object(FileFormat::Pe)))
&& !self.pdbs_allowed
{
warn!("PDBs and PEs are not supported by the configured Sentry server");
// This is validated additionally in .valid_format()
}

// Checks whether Portable PDBs were *explicitly* requested on the command line.
if self
.formats
.contains(&DifFormat::Object(FileFormat::PortablePdb))
&& !self.portablepdbs_allowed
{
warn!("Portable PDBs are not supported by the configured Sentry server");
// This is validated additionally in .valid_format()
}

// Checks whether BCSymbolMaps and PLists are **explicitly** requested on the command line.
if (self.formats.contains(&DifFormat::BcSymbolMap)
|| self.formats.contains(&DifFormat::PList))
&& !self.bcsymbolmaps_allowed
{
warn!("BCSymbolMaps are not supported by the configured Sentry server");
}

if self.upload_il2cpp_mappings && !self.il2cpp_mappings_allowed {
warn!("il2cpp line mappings are not supported by the configured Sentry server");
}
}

/// Determines if this `DebugId` matches the search criteria.
fn valid_id(&self, id: DebugId) -> bool {
self.ids.is_empty() || self.ids.contains(&id)
Expand All @@ -1542,11 +1472,6 @@ impl<'a> DifUpload<'a> {
fn valid_format(&self, format: DifFormat) -> bool {
match format {
DifFormat::Object(FileFormat::Unknown) => false,
DifFormat::Object(FileFormat::Pdb) if !self.pdbs_allowed => false,
DifFormat::Object(FileFormat::Pe) if !self.pdbs_allowed => false,
DifFormat::Object(FileFormat::SourceBundle) if !self.sources_allowed => false,
DifFormat::Object(FileFormat::PortablePdb) if !self.portablepdbs_allowed => false,
DifFormat::BcSymbolMap | DifFormat::PList if !self.bcsymbolmaps_allowed => false,
format => self.formats.is_empty() || self.formats.contains(&format),
}
}
Expand Down
Loading