diff --git a/src/commands/build/upload.rs b/src/commands/build/upload.rs index c47e948df2..bf24d84b8f 100644 --- a/src/commands/build/upload.rs +++ b/src/commands/build/upload.rs @@ -325,7 +325,15 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { } ); for (path, reason) in errored_paths_and_reasons { - warn!(" - {} ({})", path.display(), reason); + let reason_str = reason.to_string(); + // Provide specific guidance for project not found errors + if reason_str.contains("Project not found") { + warn!(" - {}", path.display()); + warn!(" Project not found. Ensure that you configured the correct project and organization."); + warn!(" Use --project and --org flags to specify the correct values."); + } else { + warn!(" - {} ({})", path.display(), reason); + } } } diff --git a/tests/integration/_cases/build/build-upload-nonexistent-project.trycmd b/tests/integration/_cases/build/build-upload-nonexistent-project.trycmd new file mode 100644 index 0000000000..5d38a38c04 --- /dev/null +++ b/tests/integration/_cases/build/build-upload-nonexistent-project.trycmd @@ -0,0 +1,15 @@ +``` +$ sentry-cli build upload tests/integration/_fixtures/build/apk.apk --project nonexistentproject +? failed +[..]WARN[..]EXPERIMENTAL: The build subcommand is experimental. The command is subject to breaking changes and may be removed without notice in any release. + WARN [..] Could not detect base branch reference: [..] + WARN [..] Failed to upload 1 file: + WARN [..] - [..]apk.apk + WARN [..] Project not found. Ensure that you configured the correct project and organization. + WARN [..] Use --project and --org flags to specify the correct values. +error: Failed to upload any files + +Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output. +Please attach the full debug log to all bug reports. + +``` \ No newline at end of file diff --git a/tests/integration/build/upload.rs b/tests/integration/build/upload.rs index 93d5ca9ddd..b1cae95549 100644 --- a/tests/integration/build/upload.rs +++ b/tests/integration/build/upload.rs @@ -74,6 +74,25 @@ fn command_build_upload_invalid_ipa() { .run_and_assert(AssertCommand::Failure); } +#[test] +fn command_build_upload_nonexistent_project() { + TestManager::new() + .mock_endpoint( + MockEndpointBuilder::new("GET", "/api/0/organizations/wat-org/chunk-upload/") + .with_response_file("build/get-chunk-upload.json"), + ) + .mock_endpoint( + MockEndpointBuilder::new( + "POST", + "/api/0/projects/wat-org/nonexistentproject/files/preprodartifacts/assemble/", + ) + .with_status(404) + .with_response_body(r#"{"detail":"Project not found. Ensure that you configured the correct project and organization."}"#), + ) + .register_trycmd_test("build/build-upload-nonexistent-project.trycmd") + .with_default_token(); +} + #[test] fn command_build_upload_apk_all_uploaded() { TestManager::new()