Skip to content

Commit 22dd886

Browse files
runningcodechromy
authored andcommitted
feat(build): Improve error messages for nonexistent projects
When 'sentry-cli build upload' fails due to a nonexistent project, provide specific guidance to users about using --project and --org flags. Fixes EME-175
1 parent 8a6a961 commit 22dd886

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

src/commands/build/upload.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,17 +326,11 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
326326
);
327327
for (path, reason) in errored_paths_and_reasons {
328328
let reason_str = reason.to_string();
329-
// Check if this is a specific API error we can provide better messaging for
329+
// Provide specific guidance for project not found errors
330330
if reason_str.contains("Project not found") {
331331
warn!(" - {}", path.display());
332332
warn!(" Project not found. Ensure that you configured the correct project and organization.");
333333
warn!(" Use --project and --org flags to specify the correct values.");
334-
} else if reason_str.contains("organization not found")
335-
|| reason_str.contains("Organization not found")
336-
{
337-
warn!(" - {}", path.display());
338-
warn!(" Organization not found. Ensure that you configured the correct organization.");
339-
warn!(" Use --org flag to specify the correct organization.");
340334
} else {
341335
warn!(" - {} ({})", path.display(), reason);
342336
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
```
2+
$ sentry-cli build upload tests/integration/_fixtures/build/apk.apk --project nonexistentproject
3+
? failed
4+
[..]WARN[..]EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release.
5+
WARN [..] Failed to upload 1 file:
6+
WARN [..] - [..]apk.apk
7+
WARN [..] Project not found. Ensure that you configured the correct project and organization.
8+
WARN [..] Use --project and --org flags to specify the correct values.
9+
error: Failed to upload any files
10+
11+
Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
12+
Please attach the full debug log to all bug reports.
13+
14+
```

tests/integration/build/upload.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,25 @@ fn command_build_upload_invalid_ipa() {
7474
.run_and_assert(AssertCommand::Failure);
7575
}
7676

77+
#[test]
78+
fn command_build_upload_nonexistent_project() {
79+
TestManager::new()
80+
.mock_endpoint(
81+
MockEndpointBuilder::new("GET", "/api/0/organizations/wat-org/chunk-upload/")
82+
.with_response_file("build/get-chunk-upload.json"),
83+
)
84+
.mock_endpoint(
85+
MockEndpointBuilder::new(
86+
"POST",
87+
"/api/0/projects/wat-org/nonexistentproject/files/preprodartifacts/assemble/",
88+
)
89+
.with_status(404)
90+
.with_response_body(r#"{"detail":"Project not found. Ensure that you configured the correct project and organization."}"#),
91+
)
92+
.register_trycmd_test("build/build-upload-nonexistent-project.trycmd")
93+
.with_default_token();
94+
}
95+
7796
#[test]
7897
fn command_build_upload_apk_all_uploaded() {
7998
TestManager::new()

0 commit comments

Comments
 (0)