Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: warn about missing SENTRY_RELEASE when it's set to empty string #2394

Merged
merged 5 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/api/data_types/chunking/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct ChunkedArtifactRequest<'a> {
pub chunks: &'a [Digest],
#[serde(skip_serializing_if = "Vec::is_empty")]
pub projects: Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(skip_serializing_if = "version_is_empty")]
pub version: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
pub dist: Option<&'a str>,
Expand All @@ -22,3 +22,10 @@ pub struct AssembleArtifactsResponse {
pub missing_chunks: Vec<Digest>,
pub detail: Option<String>,
}

fn version_is_empty(version: &Option<&str>) -> bool {
match version {
Some(v) => v.is_empty(),
None => true,
}
}
8 changes: 6 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,12 @@ impl Config {
matches
.get_one::<String>("release")
.cloned()
.or_else(|| env::var("SENTRY_RELEASE").ok())
.ok_or_else(|| format_err!("A release slug is required (provide with --release)"))
.or_else(|| {
env::var("SENTRY_RELEASE")
.ok()
.filter(|v| !v.is_empty())
})
.ok_or_else(|| format_err!("A release slug is required (provide with --release or by setting the SENTRY_RELEASE environment variable)"))
}

// Backward compatibility with `releases files <VERSION>` commands.
Expand Down
4 changes: 2 additions & 2 deletions src/utils/file_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn initialize_legacy_release_upload(context: &UploadContext) -> Result<()> {
},
)?;
} else {
bail!("This version of Sentry does not support artifact bundles. A release slug is required (provide with --release)");
bail!("This version of Sentry does not support artifact bundles. A release slug is required (provide with --release or by setting the SENTRY_RELEASE environment variable)");
}
Ok(())
}
Expand All @@ -96,7 +96,7 @@ pub struct UploadContext<'a> {
impl UploadContext<'_> {
pub fn release(&self) -> Result<&str> {
self.release
.ok_or_else(|| anyhow!("A release slug is required (provide with --release)"))
.ok_or_else(|| anyhow!("A release slug is required (provide with --release or by setting the SENTRY_RELEASE environment variable)"))
}
}

Expand Down
Loading