Skip to content

Commit 42b1fd4

Browse files
fix(chunk): Fail with org not found on 404 to chunk endpoint (#2930)
⚠️ **Breaking change:** Do not merge until ready to release in a major. As Sentry CLI 3.0.0 will only support Sentry servers with chunk uploading support, we can now assume that 404 errors from the `/organizations/{org}/chunk-upload/` endpoint are due to the organization not existing, and not due to the chunk upload endpoint not existing. - Resolves #2900 - Resolves [CLI-211](https://linear.app/getsentry/issue/CLI-211/assume-404-when-getting-chunk-upload-endpoint-is-due-to-non-existent) ________ BREAKING CHANGE: Several subcommands no longer support Sentry servers which lack support for chunked uploads.
1 parent d4366f6 commit 42b1fd4

File tree

13 files changed

+70
-106
lines changed

13 files changed

+70
-106
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
- Removed the `upload-proguard` subcommand's `--app-id`, `--version`, and `--version-code` arguments ([#2876](https://github.com/getsentry/sentry-cli/pull/2876)). Users using these arguments should stop using them, as they are unnecessary. The information passed to these arguments is no longer visible in Sentry.
1212

13+
### Fixes
14+
15+
- Fixed misleading error message claiming the server doesn't support chunk uploading when the actual error was a non-existent organization ([#2930](https://github.com/getsentry/sentry-cli/pull/2930)).
16+
1317
## 2.58.3
1418

1519
### Improvements

src/api/errors/api_error.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ pub(in crate::api) enum ApiErrorKind {
2828
ProjectNotFound,
2929
#[error("Release not found. Ensure that you configured the correct release, project, and organization.")]
3030
ReleaseNotFound,
31-
#[error("chunk upload endpoint not supported by sentry server")]
32-
ChunkUploadNotSupported,
3331
#[error("API request failed")]
3432
RequestFailed,
3533
#[error("could not compress data")]
@@ -63,6 +61,9 @@ impl ApiError {
6361
}
6462
}
6563

64+
// This method is currently only used in the macOS binary, there is no reason
65+
// why not to expose it on other platforms, if we ever need it.
66+
#[cfg(target_os = "macos")]
6667
pub(in crate::api) fn kind(&self) -> ApiErrorKind {
6768
self.inner
6869
}

src/api/mod.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -956,21 +956,10 @@ impl<'a> AuthenticatedApi<'a> {
956956
}
957957

958958
/// Get the server configuration for chunked file uploads.
959-
pub fn get_chunk_upload_options(&self, org: &str) -> ApiResult<Option<ChunkServerOptions>> {
959+
pub fn get_chunk_upload_options(&self, org: &str) -> ApiResult<ChunkServerOptions> {
960960
let url = format!("/organizations/{}/chunk-upload/", PathArg(org));
961-
match self
962-
.get(&url)?
963-
.convert_rnf::<ChunkServerOptions>(ApiErrorKind::ChunkUploadNotSupported)
964-
{
965-
Ok(options) => Ok(Some(options)),
966-
Err(error) => {
967-
if error.kind() == ApiErrorKind::ChunkUploadNotSupported {
968-
Ok(None)
969-
} else {
970-
Err(error)
971-
}
972-
}
973-
}
961+
self.get(&url)?
962+
.convert_rnf::<ChunkServerOptions>(ApiErrorKind::OrganizationNotFound)
974963
}
975964

976965
/// Request DIF assembling and processing from chunks.

src/commands/build/upload.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,7 @@ fn upload_file(
557557
build_configuration.unwrap_or("unknown"),
558558
);
559559

560-
let chunk_upload_options = api.get_chunk_upload_options(org)?.ok_or_else(|| {
561-
anyhow!(
562-
"The Sentry server lacks chunked uploading support, which \
563-
is required for build uploads. {SELF_HOSTED_ERROR_HINT}"
564-
)
565-
})?;
560+
let chunk_upload_options = api.get_chunk_upload_options(org)?;
566561

567562
if !chunk_upload_options.supports(ChunkUploadCapability::PreprodArtifacts) {
568563
bail!(

src/commands/dart_symbol_map/upload.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ pub(super) fn execute(args: DartSymbolMapUploadArgs) -> Result<()> {
132132
))?;
133133
let chunk_upload_options = api
134134
.authenticated()?
135-
.get_chunk_upload_options(org)?
136-
.ok_or_else(|| anyhow::anyhow!(
137-
"server does not support chunked uploading. Please update your Sentry server."
138-
))?;
135+
.get_chunk_upload_options(org)?;
139136

140137
if !chunk_upload_options.supports(ChunkUploadCapability::DartSymbolMap) {
141138
bail!(

src/commands/files/upload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
159159
note: None,
160160
wait,
161161
max_wait,
162-
chunk_upload_options: chunk_upload_options.as_ref(),
162+
chunk_upload_options: &chunk_upload_options,
163163
};
164164

165165
let path = Path::new(matches.get_one::<String>("path").unwrap());

src/commands/react_native/appcenter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
202202
note: None,
203203
wait,
204204
max_wait,
205-
chunk_upload_options: chunk_upload_options.as_ref(),
205+
chunk_upload_options: &chunk_upload_options,
206206
})?;
207207
}
208208
Some(dists) => {
@@ -220,7 +220,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
220220
note: None,
221221
wait,
222222
max_wait,
223-
chunk_upload_options: chunk_upload_options.as_ref(),
223+
chunk_upload_options: &chunk_upload_options,
224224
})?;
225225
}
226226
}

src/commands/react_native/gradle.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
129129
note: None,
130130
wait,
131131
max_wait,
132-
chunk_upload_options: chunk_upload_options.as_ref(),
132+
chunk_upload_options: &chunk_upload_options,
133133
})?;
134134
}
135135
} else {
@@ -142,7 +142,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
142142
note: None,
143143
wait,
144144
max_wait,
145-
chunk_upload_options: chunk_upload_options.as_ref(),
145+
chunk_upload_options: &chunk_upload_options,
146146
})?;
147147
}
148148

src/commands/react_native/xcode.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
351351
note: None,
352352
wait,
353353
max_wait,
354-
chunk_upload_options: chunk_upload_options.as_ref(),
354+
chunk_upload_options: &chunk_upload_options,
355355
})?;
356356
} else {
357357
let (dist, release_name) = match (&dist_from_env, &release_from_env) {
@@ -386,7 +386,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
386386
note: None,
387387
wait,
388388
max_wait,
389-
chunk_upload_options: chunk_upload_options.as_ref(),
389+
chunk_upload_options: &chunk_upload_options,
390390
})?;
391391
}
392392
Some(dists) => {
@@ -399,7 +399,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
399399
note: None,
400400
wait,
401401
max_wait,
402-
chunk_upload_options: chunk_upload_options.as_ref(),
402+
chunk_upload_options: &chunk_upload_options,
403403
})?;
404404
}
405405
}

src/commands/sourcemaps/upload.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
437437
log::warn!("The --use-artifact-bundle option and the SENTRY_FORCE_ARTIFACT_BUNDLES environment variable \
438438
are both deprecated, and both will be removed in the next major version.");
439439

440-
if let Some(ref mut options) = chunk_upload_options {
441-
if !options.supports(ChunkUploadCapability::ArtifactBundles) {
442-
options.accept.push(ChunkUploadCapability::ArtifactBundles);
443-
}
440+
if !chunk_upload_options.supports(ChunkUploadCapability::ArtifactBundles) {
441+
chunk_upload_options
442+
.accept
443+
.push(ChunkUploadCapability::ArtifactBundles);
444444
}
445445
}
446446

@@ -461,7 +461,7 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
461461
note: matches.get_one::<String>("note").map(String::as_str),
462462
wait,
463463
max_wait,
464-
chunk_upload_options: chunk_upload_options.as_ref(),
464+
chunk_upload_options: &chunk_upload_options,
465465
};
466466

467467
if matches.get_flag("strict") {

0 commit comments

Comments
 (0)