Skip to content

Commit

Permalink
fix(utils): Filter out empty string releases (#2591)
Browse files Browse the repository at this point in the history
Instead of only allowing truthy releases, we were allowing all non-`None` releases, which includes empty strings.
  • Loading branch information
sentrivana authored Dec 13, 2023
1 parent 4731312 commit 64c42ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sentry_sdk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def get_default_release():
return release

release = get_git_revision()
if release is not None:
if release:
return release

for var in (
Expand Down
13 changes: 13 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from sentry_sdk.utils import (
Components,
Dsn,
get_default_release,
get_error_message,
get_git_revision,
is_valid_sample_rate,
Expand Down Expand Up @@ -579,3 +580,15 @@ def test_devnull_not_found():
revision = get_git_revision()

assert revision is None


def test_default_release():
release = get_default_release()
assert release is not None


def test_default_release_empty_string():
with mock.patch("sentry_sdk.utils.get_git_revision", return_value=""):
release = get_default_release()

assert release is None

0 comments on commit 64c42ca

Please sign in to comment.