diff --git a/CHANGELOG.md b/CHANGELOG.md index f7848f55e2..0c7edb1025 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- (snapshots) Reject snapshot uploads that have a PR number but no base SHA, since comparisons cannot work without a base reference ([#3300](https://github.com/getsentry/sentry-cli/pull/3300)) + ## 3.4.2 ### Fixes diff --git a/src/commands/build/snapshots.rs b/src/commands/build/snapshots.rs index c12b8a465a..6484ee2064 100644 --- a/src/commands/build/snapshots.rs +++ b/src/commands/build/snapshots.rs @@ -118,6 +118,14 @@ pub fn execute(matches: &ArgMatches) -> Result<()> { // Always collect git metadata, but only perform automatic inference when enabled let vcs_info = collect_git_metadata(matches, &config, should_collect_git_metadata); + if vcs_info.pr_number.is_some() && vcs_info.base_sha.is_none() { + anyhow::bail!( + "A PR number was provided but no base SHA could be determined. \ + Snapshot comparisons require a base SHA to identify the base build. \ + Pass --base-sha explicitly or ensure your CI environment exposes the merge base." + ); + } + debug!("Scanning for images in: {}", dir_path.display()); debug!("Organization: {org}"); debug!("Project: {project}");