Skip to content

Commit c9e87cf

Browse files
ref: Assume chunk uploading support (#3064)
### Description Assume that the Sentry server supports all file types we would like to upload. This change fixes compatibility with uploading ProGuard files self-hosted version 24.11.1, which [can receive chunk-uploaded ProGuard files](getsentry/sentry@7c7e79f), but [does not declare support in the `accept` field, yet](getsentry/sentry@e0b7ff2). This will allow us to expand Sentry CLI 3.x's official support to all self-hosted versions above 24.11.1. We also no longer check the `accept` field during `dart-symbol-map` and `build` uploads. As not all versions ≥24.11.1 support these features, this means that users on a self-hosted version that supports these features tries to use the command, they will no longer get an error message that states that their server lacks uploading support for those file types if they attempt to upload it. But, I think this is okay, as long as we are clear what versions are supported for these features. ### Issues - Resolves #3050 - Resolves [CLI-254](https://linear.app/getsentry/issue/CLI-254/assume-chunk-upload-support)
1 parent f316566 commit c9e87cf

File tree

10 files changed

+61
-77
lines changed

10 files changed

+61
-77
lines changed

src/api/data_types/chunking/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ pub use self::compression::ChunkCompression;
1515
pub use self::dif::{AssembleDifsRequest, AssembleDifsResponse, ChunkedDifRequest};
1616
pub use self::file_state::ChunkedFileState;
1717
pub use self::hash_algorithm::ChunkHashAlgorithm;
18-
pub use self::upload::{ChunkServerOptions, ChunkUploadCapability};
18+
pub use self::upload::ChunkServerOptions;

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

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use super::*;
22

3-
mod capability;
43
mod options;
54

6-
pub use self::capability::ChunkUploadCapability;
75
pub use self::options::ChunkServerOptions;

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::num::NonZeroUsize;
22

33
use serde::Deserialize;
44

5-
use super::{ChunkCompression, ChunkHashAlgorithm, ChunkUploadCapability};
5+
use super::{ChunkCompression, ChunkHashAlgorithm};
66

77
/// Chunk upload options which are set by the Sentry server.
88
#[derive(Debug, Deserialize)]
@@ -23,13 +23,4 @@ pub struct ChunkServerOptions {
2323
pub concurrency: u8,
2424
#[serde(default)]
2525
pub compression: Vec<ChunkCompression>,
26-
#[serde(default)]
27-
pub accept: Vec<ChunkUploadCapability>,
28-
}
29-
30-
impl ChunkServerOptions {
31-
/// Returns whether the given capability is accepted by the chunk upload endpoint.
32-
pub fn supports(&self, capability: ChunkUploadCapability) -> bool {
33-
self.accept.contains(&capability)
34-
}
3526
}

src/commands/build/upload.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use symbolic::common::ByteView;
1111
use zip::write::SimpleFileOptions;
1212
use zip::{DateTime, ZipWriter};
1313

14-
use crate::api::{
15-
Api, AuthenticatedApi, ChunkUploadCapability, ChunkedBuildRequest, ChunkedFileState, VcsInfo,
16-
};
14+
use crate::api::{Api, AuthenticatedApi, ChunkedBuildRequest, ChunkedFileState, VcsInfo};
1715
use crate::config::Config;
1816
use crate::utils::args::ArgExt as _;
1917
#[cfg(all(target_os = "macos", target_arch = "aarch64"))]
@@ -42,6 +40,7 @@ pub fn make_command(command: Command) -> Command {
4240
"The path to the build to upload. Supported files include Apk, and Aab.";
4341
command
4442
.about("Upload builds to a project.")
43+
.long_about("Upload builds to a project.\n\nThis feature only works with Sentry SaaS.")
4544
.org_arg()
4645
.project_arg(false)
4746
.arg(
@@ -599,23 +598,13 @@ fn upload_file(
599598
release_notes: Option<&str>,
600599
vcs_info: &VcsInfo<'_>,
601600
) -> Result<String> {
602-
const SELF_HOSTED_ERROR_HINT: &str = "If you are using a self-hosted Sentry server, \
603-
update to the latest version of Sentry to use the build upload command.";
604-
605601
debug!(
606602
"Uploading file to organization: {org}, project: {project}, build_configuration: {}, vcs_info: {vcs_info:?}",
607603
build_configuration.unwrap_or("unknown"),
608604
);
609605

610606
let chunk_upload_options = api.get_chunk_upload_options(org)?;
611607

612-
if !chunk_upload_options.supports(ChunkUploadCapability::PreprodArtifacts) {
613-
bail!(
614-
"The Sentry server lacks support for receiving files uploaded \
615-
with this command. {SELF_HOSTED_ERROR_HINT}"
616-
);
617-
}
618-
619608
let progress_style =
620609
ProgressStyle::default_spinner().template("{spinner} Preparing for upload...");
621610
let pb = ProgressBar::new_spinner();

src/commands/dart_symbol_map/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const GROUP_ABOUT: &str = "Manage Dart/Flutter symbol maps for Sentry.";
77
const UPLOAD_ABOUT: &str =
88
"Upload a Dart/Flutter symbol map (dartsymbolmap) for deobfuscating Dart exception types.";
99
const UPLOAD_LONG_ABOUT: &str =
10-
"Upload a Dart/Flutter symbol map (dartsymbolmap) for deobfuscating Dart exception types.{n}{n}Examples:{n} sentry-cli dart-symbol-map upload --org my-org --project my-proj path/to/dartsymbolmap.json path/to/debug/file{n}{n}The mapping must be a JSON array of strings with an even number of entries (pairs).{n}The debug file must contain exactly one Debug ID.";
10+
"Upload a Dart/Flutter symbol map (dartsymbolmap) for deobfuscating Dart exception types.{n}{n}Examples:{n} sentry-cli dart-symbol-map upload --org my-org --project my-proj path/to/dartsymbolmap.json path/to/debug/file{n}{n}The mapping must be a JSON array of strings with an even number of entries (pairs).{n}The debug file must contain exactly one Debug ID. {n}{n}\
11+
This command is supported on Sentry SaaS and self-hosted versions ≥25.8.0.";
1112

1213
#[derive(Args)]
1314
pub(super) struct DartSymbolMapArgs {

src/commands/dart_symbol_map/upload.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::path::Path;
66
use anyhow::{bail, Context as _, Result};
77
use clap::Args;
88

9-
use crate::api::{Api, ChunkUploadCapability};
9+
use crate::api::Api;
1010
use crate::config::Config;
1111
use crate::constants::{DEFAULT_MAX_DIF_SIZE, DEFAULT_MAX_WAIT};
1212
use crate::utils::chunks::{upload_chunked_objects, Assemblable, ChunkOptions, Chunked};
@@ -134,11 +134,6 @@ pub(super) fn execute(args: DartSymbolMapUploadArgs) -> Result<()> {
134134
.authenticated()?
135135
.get_chunk_upload_options(org)?;
136136

137-
if !chunk_upload_options.supports(ChunkUploadCapability::DartSymbolMap) {
138-
bail!(
139-
"Server does not support uploading Dart symbol maps via chunked upload. Please update your Sentry server."
140-
);
141-
}
142137

143138
// Early file size check against server or default limits (same as debug files)
144139
let effective_max_file_size = if chunk_upload_options.max_file_size > 0 {

src/commands/upload_proguard.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use symbolic::common::ByteView;
88
use uuid::Uuid;
99

1010
use crate::api::Api;
11-
use crate::api::ChunkUploadCapability;
1211
use crate::config::Config;
1312
use crate::utils::android::dump_proguard_uuids_as_properties;
1413
use crate::utils::args::ArgExt as _;
@@ -148,10 +147,5 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
148147
let (org, project) = config.get_org_and_project(matches)?;
149148

150149
let chunk_upload_options = authenticated_api.get_chunk_upload_options(&org)?;
151-
152-
if chunk_upload_options.supports(ChunkUploadCapability::Proguard) {
153-
proguard::chunk_upload(&mappings, chunk_upload_options, &org, &project)
154-
} else {
155-
Err(anyhow::anyhow!("Server does not support uploading ProGuard mappings via chunked upload. Please update your Sentry server."))
156-
}
150+
proguard::chunk_upload(&mappings, chunk_upload_options, &org, &project)
157151
}

tests/integration/_cases/build/build-upload-help-macos.trycmd

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,63 +3,86 @@ $ sentry-cli build upload --help
33
? success
44
Upload builds to a project.
55

6-
Usage: sentry-cli[EXE] build upload [OPTIONS] <PATH>...
6+
This feature only works with Sentry SaaS.
7+
8+
Usage: sentry-cli build upload [OPTIONS] <PATH>...
79

810
Arguments:
9-
<PATH>... The path to the build to upload. Supported files include Apk, Aab, XCArchive, and IPA.
11+
<PATH>...
12+
The path to the build to upload. Supported files include Apk, Aab, XCArchive, and IPA.
1013

1114
Options:
1215
-o, --org <ORG>
1316
The organization ID or slug.
17+
1418
--header <KEY:VALUE>
1519
Custom headers that should be attached to all requests
1620
in key:value format.
21+
1722
-p, --project <PROJECT>
1823
The project ID or slug.
24+
1925
--auth-token <AUTH_TOKEN>
2026
Use the given Sentry auth token.
27+
2128
--head-sha <head_sha>
2229
The VCS commit sha to use for the upload. If not provided, the current commit sha will be
2330
used.
31+
2432
--base-sha <base_sha>
2533
The VCS commit's base sha to use for the upload. If not provided, the merge-base of the
2634
current and remote branch will be used.
35+
2736
--log-level <LOG_LEVEL>
2837
Set the log output verbosity. [possible values: trace, debug, info, warn, error]
38+
2939
--quiet
3040
Do not print any output while preserving correct exit code. This flag is currently
31-
implemented only for selected subcommands. [aliases: --silent]
41+
implemented only for selected subcommands.
42+
43+
[aliases: --silent]
44+
3245
--vcs-provider <vcs_provider>
3346
The VCS provider to use for the upload. If not provided, the current provider will be
3447
used.
48+
3549
--head-repo-name <head_repo_name>
3650
The name of the git repository to use for the upload (e.g. organization/repository). If
3751
not provided, the current repository will be used.
52+
3853
--base-repo-name <base_repo_name>
3954
The name of the git repository to use for the upload (e.g. organization/repository). If
4055
not provided, the current repository will be used.
56+
4157
--head-ref <head_ref>
4258
The reference (branch) to use for the upload. If not provided, the current reference will
4359
be used.
60+
4461
--base-ref <base_ref>
4562
The base reference (branch) to use for the upload. If not provided, the merge-base with
4663
the remote tracking branch will be used.
64+
4765
--pr-number <pr_number>
4866
The pull request number to use for the upload. If not provided and running in a
4967
pull_request-triggered GitHub Actions workflow, the PR number will be automatically
5068
detected from GitHub Actions environment variables.
69+
5170
--build-configuration <build_configuration>
5271
The build configuration to use for the upload. If not provided, the current version will
5372
be used.
73+
5474
--release-notes <release_notes>
5575
The release notes to use for the upload.
76+
5677
--force-git-metadata
5778
Force collection and sending of git metadata (branch, commit, etc.). If neither this nor
5879
--no-git-metadata is specified, git metadata is automatically collected when running in
5980
most CI environments.
81+
6082
--no-git-metadata
6183
Disable collection and sending of git metadata.
84+
6285
-h, --help
63-
Print help
86+
Print help (see a summary with '-h')
6487

6588
```

tests/integration/_cases/build/build-upload-help-not-macos.trycmd

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,86 @@
22
$ sentry-cli build upload --help
33
Upload builds to a project.
44

5+
This feature only works with Sentry SaaS.
6+
57
Usage: sentry-cli[EXE] build upload [OPTIONS] <PATH>...
68

79
Arguments:
8-
<PATH>... The path to the build to upload. Supported files include Apk, and Aab.
10+
<PATH>...
11+
The path to the build to upload. Supported files include Apk, and Aab.
912

1013
Options:
1114
-o, --org <ORG>
1215
The organization ID or slug.
16+
1317
--header <KEY:VALUE>
1418
Custom headers that should be attached to all requests
1519
in key:value format.
20+
1621
-p, --project <PROJECT>
1722
The project ID or slug.
23+
1824
--auth-token <AUTH_TOKEN>
1925
Use the given Sentry auth token.
26+
2027
--head-sha <head_sha>
2128
The VCS commit sha to use for the upload. If not provided, the current commit sha will be
2229
used.
30+
2331
--base-sha <base_sha>
2432
The VCS commit's base sha to use for the upload. If not provided, the merge-base of the
2533
current and remote branch will be used.
34+
2635
--log-level <LOG_LEVEL>
2736
Set the log output verbosity. [possible values: trace, debug, info, warn, error]
37+
2838
--quiet
2939
Do not print any output while preserving correct exit code. This flag is currently
30-
implemented only for selected subcommands. [aliases: --silent]
40+
implemented only for selected subcommands.
41+
42+
[aliases: --silent]
43+
3144
--vcs-provider <vcs_provider>
3245
The VCS provider to use for the upload. If not provided, the current provider will be
3346
used.
47+
3448
--head-repo-name <head_repo_name>
3549
The name of the git repository to use for the upload (e.g. organization/repository). If
3650
not provided, the current repository will be used.
51+
3752
--base-repo-name <base_repo_name>
3853
The name of the git repository to use for the upload (e.g. organization/repository). If
3954
not provided, the current repository will be used.
55+
4056
--head-ref <head_ref>
4157
The reference (branch) to use for the upload. If not provided, the current reference will
4258
be used.
59+
4360
--base-ref <base_ref>
4461
The base reference (branch) to use for the upload. If not provided, the merge-base with
4562
the remote tracking branch will be used.
63+
4664
--pr-number <pr_number>
4765
The pull request number to use for the upload. If not provided and running in a
4866
pull_request-triggered GitHub Actions workflow, the PR number will be automatically
4967
detected from GitHub Actions environment variables.
68+
5069
--build-configuration <build_configuration>
5170
The build configuration to use for the upload. If not provided, the current version will
5271
be used.
72+
5373
--release-notes <release_notes>
5474
The release notes to use for the upload.
75+
5576
--force-git-metadata
5677
Force collection and sending of git metadata (branch, commit, etc.). If neither this nor
5778
--no-git-metadata is specified, git metadata is automatically collected when running in
5879
most CI environments.
80+
5981
--no-git-metadata
6082
Disable collection and sending of git metadata.
83+
6184
-h, --help
62-
Print help
85+
Print help (see a summary with '-h')
6386

6487
```

0 commit comments

Comments
 (0)