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
9 changes: 0 additions & 9 deletions src/api/data_types/chunking/upload/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ use serde::{Deserialize, Deserializer};

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum ChunkUploadCapability {
/// Chunked upload of standalone artifact bundles
ArtifactBundles,

/// Like `ArtifactBundles`, but with deduplicated chunk
/// upload.
ArtifactBundlesV2,

/// Upload of Dart symbol maps
DartSymbolMap,

Expand All @@ -28,8 +21,6 @@ impl<'de> Deserialize<'de> for ChunkUploadCapability {
D: Deserializer<'de>,
{
Ok(match String::deserialize(deserializer)?.as_str() {
"artifact_bundles" => ChunkUploadCapability::ArtifactBundles,
"artifact_bundles_v2" => ChunkUploadCapability::ArtifactBundlesV2,
"dartsymbolmap" => ChunkUploadCapability::DartSymbolMap,
"preprod_artifacts" => ChunkUploadCapability::PreprodArtifacts,
"proguard" => ChunkUploadCapability::Proguard,
Expand Down
26 changes: 0 additions & 26 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,32 +749,6 @@ impl AuthenticatedApi<'_> {
.convert_rnf(ApiErrorKind::ProjectNotFound)
}

#[deprecated = "release bundle uploads are deprecated in favor of artifact bundle uploads"]
pub fn assemble_release_artifacts(
&self,
org: &str,
release: &str,
checksum: Digest,
chunks: &[Digest],
) -> ApiResult<AssembleArtifactsResponse> {
let url = format!(
"/organizations/{}/releases/{}/assemble/",
PathArg(org),
PathArg(release)
);

self.request(Method::Post, &url)?
.with_json_body(&ChunkedArtifactRequest {
checksum,
chunks,
projects: &[],
version: None,
dist: None,
})?
.send()?
.convert_rnf(ApiErrorKind::ReleaseNotFound)
}

pub fn assemble_artifact_bundle(
&self,
org: &str,
Expand Down
10 changes: 2 additions & 8 deletions src/commands/sourcemaps/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use glob::{glob_with, MatchOptions};
use itertools::Itertools as _;
use log::{debug, warn};

use crate::api::{Api, ChunkUploadCapability};
use crate::api::Api;
use crate::config::Config;
use crate::constants::DEFAULT_MAX_WAIT;
use crate::utils::args::validate_distribution;
Expand Down Expand Up @@ -429,19 +429,13 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
let projects = config.get_projects(matches)?;
let api = Api::current();
let mut processor = SourceMapProcessor::new();
let mut chunk_upload_options = api.authenticated()?.get_chunk_upload_options(&org)?;
let chunk_upload_options = api.authenticated()?.get_chunk_upload_options(&org)?;

if matches.get_flag("use_artifact_bundle")
|| env::var("SENTRY_FORCE_ARTIFACT_BUNDLES").ok().as_deref() == Some("1")
{
log::warn!("The --use-artifact-bundle option and the SENTRY_FORCE_ARTIFACT_BUNDLES environment variable \
are both deprecated, and both will be removed in the next major version.");

if !chunk_upload_options.supports(ChunkUploadCapability::ArtifactBundles) {
chunk_upload_options
.accept
.push(ChunkUploadCapability::ArtifactBundles);
}
}

if matches.contains_id("bundle") && matches.contains_id("bundle_sourcemap") {
Expand Down
126 changes: 21 additions & 105 deletions src/utils/file_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ use std::str;
use std::sync::Arc;
use std::time::{Duration, Instant};

use anyhow::{anyhow, bail, Result};
use anyhow::{bail, Result};
use console::style;
use sha1_smol::Digest;
use symbolic::common::ByteView;
use symbolic::debuginfo::js;
use symbolic::debuginfo::sourcebundle::SourceFileType;

use crate::api::NewRelease;
use crate::api::{Api, ChunkServerOptions, ChunkUploadCapability};
use crate::api::{Api, ChunkServerOptions};
use crate::constants::DEFAULT_MAX_WAIT;
use crate::utils::chunks::{upload_chunks, Chunk, ASSEMBLE_POLL_INTERVAL};
use crate::utils::fs::get_sha1_checksums;
Expand All @@ -25,39 +24,6 @@ use crate::utils::source_bundle;

use super::file_search::ReleaseFileMatch;

/// Old versions of Sentry cannot assemble artifact bundles straight away, they require
/// that those bundles are associated to a release.
///
/// This function checks whether the configured server supports artifact bundles
/// and only creates a release if the server requires that.
pub fn initialize_legacy_release_upload(context: &UploadContext) -> Result<()> {
// if the remote sentry service supports artifact bundles, we don't
// need to do anything here. Artifact bundles will also only work
// if a project is provided which is technically unnecessary for the
// legacy upload though it will unlikely to be what users want.
let chunk_options = context.chunk_upload_options;
if chunk_options.supports(ChunkUploadCapability::ArtifactBundles)
|| chunk_options.supports(ChunkUploadCapability::ArtifactBundlesV2)
{
return Ok(());
}

if let Some(version) = context.release {
let api = Api::current();
api.authenticated()?.new_release(
context.org,
&NewRelease {
version: version.to_owned(),
projects: context.projects.into(),
..Default::default()
},
)?;
} else {
bail!("This version of Sentry does not support artifact bundles. A release slug is required (provide with --release or by setting the SENTRY_RELEASE environment variable)");
}
Ok(())
}

#[derive(Debug, Clone)]
pub struct UploadContext<'a> {
pub org: &'a str,
Expand All @@ -70,13 +36,6 @@ pub struct UploadContext<'a> {
pub chunk_upload_options: &'a ChunkServerOptions,
}

impl UploadContext<'_> {
pub fn release(&self) -> Result<&str> {
self.release
.ok_or_else(|| anyhow!("A release slug is required (provide with --release or by setting the SENTRY_RELEASE environment variable)"))
}
}

#[derive(Eq, PartialEq, Debug, Copy, Clone, Hash)]
pub enum LogLevel {
Warning,
Expand Down Expand Up @@ -227,8 +186,6 @@ impl<'a> FileUpload<'a> {
}

pub fn upload(&self) -> Result<()> {
// multiple projects OK
initialize_legacy_release_upload(self.context)?;
upload_files_chunked(self.context, &self.files, self.context.chunk_upload_options)
}
}
Expand Down Expand Up @@ -256,39 +213,16 @@ fn poll_assemble(
let api = Api::current();
let authenticated_api = api.authenticated()?;

let server_supports_artifact_bundles = options.supports(ChunkUploadCapability::ArtifactBundles)
|| options.supports(ChunkUploadCapability::ArtifactBundlesV2);

if !server_supports_artifact_bundles {
log::warn!(
"[DEPRECATION NOTICE] Your Sentry server does not support artifact bundle \
uploads. Falling back to deprecated release bundle upload. Support for this \
deprecated upload method will be removed in Sentry CLI 3.0.0. Please upgrade your \
Sentry server, or if you cannot upgrade, pin your Sentry CLI version to 2.x, so \
you don't get upgraded to 3.x when it is released."
);
}

let response = loop {
// prefer standalone artifact bundle upload over legacy release based upload
let response = if server_supports_artifact_bundles {
authenticated_api.assemble_artifact_bundle(
context.org,
context.projects,
checksum,
chunks,
context.release,
context.dist,
)?
} else {
#[expect(deprecated, reason = "fallback to legacy upload")]
authenticated_api.assemble_release_artifacts(
context.org,
context.release()?,
checksum,
chunks,
)?
};
let response = authenticated_api.assemble_artifact_bundle(
context.org,
context.projects,
checksum,
chunks,
context.release,
context.dist,
)?;

// Poll until there is a response, unless the user has specified to skip polling. In
// that case, we return the potentially partial response from the server. This might
Expand Down Expand Up @@ -359,23 +293,16 @@ fn upload_files_chunked(
style(">").dim(),
));

// Filter out chunks that are already on the server. This only matters if the server supports
// `ArtifactBundlesV2`, otherwise the `missing_chunks` field is meaningless.
if let Some(projects) = options
.supports(ChunkUploadCapability::ArtifactBundlesV2)
.then_some(context.projects)
{
let api = Api::current();
let response = api.authenticated()?.assemble_artifact_bundle(
context.org,
projects,
checksum,
&checksums,
context.release,
context.dist,
)?;
chunks.retain(|Chunk((digest, _))| response.missing_chunks.contains(digest));
};
let api = Api::current();
let response = api.authenticated()?.assemble_artifact_bundle(
context.org,
context.projects,
checksum,
&checksums,
context.release,
context.dist,
)?;
chunks.retain(|Chunk((digest, _))| response.missing_chunks.contains(digest));

if !chunks.is_empty() {
upload_chunks(&chunks, options, progress_style)?;
Expand Down Expand Up @@ -410,21 +337,10 @@ fn print_upload_context_details(context: &UploadContext) {
style("> Dist:").dim(),
style(context.dist.unwrap_or("None")).yellow()
);
let upload_type = if context
.chunk_upload_options
.supports(ChunkUploadCapability::ArtifactBundles)
|| context
.chunk_upload_options
.supports(ChunkUploadCapability::ArtifactBundlesV2)
{
"artifact bundle"
} else {
"release bundle"
};
println!(
"{} {}",
style("> Upload type:").dim(),
style(upload_type).yellow()
style("artifact bundle").yellow()
);
}

Expand Down
5 changes: 1 addition & 4 deletions src/utils/sourcemaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ use symbolic::debuginfo::sourcebundle::SourceFileType;
use url::Url;

use crate::utils::file_search::ReleaseFileMatch;
use crate::utils::file_upload::{
initialize_legacy_release_upload, FileUpload, SourceFile, SourceFiles, UploadContext,
};
use crate::utils::file_upload::{FileUpload, SourceFile, SourceFiles, UploadContext};
use crate::utils::fs;
use crate::utils::logging::is_quiet_mode;
use crate::utils::progress::ProgressBar;
Expand Down Expand Up @@ -666,7 +664,6 @@ impl SourceMapProcessor {
/// Uploads all files, and on success, returns the number of files that were
/// uploaded, wrapped in Ok()
pub fn upload(&mut self, context: &UploadContext<'_>) -> Result<usize> {
initialize_legacy_release_upload(context)?;
self.flush_pending_sources();

// If there is no release, we have to check that the files at least
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion tests/integration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use std::io;
use std::path::Path;

use test_utils::MockEndpointBuilder;
use test_utils::{chunk_upload, env, AssertCommand, ChunkOptions, ServerBehavior, TestManager};
use test_utils::{chunk_upload, env, AssertCommand, TestManager};

pub const UTC_DATE_FORMAT: &str = r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6,9}Z";
const VERSION: &str = env!("CARGO_PKG_VERSION");
Expand Down
Loading
Loading