diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index bf452c60a8..d547e363b6 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -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 ( diff --git a/tests/test_utils.py b/tests/test_utils.py index f8cc7874cd..71657f75c7 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -5,6 +5,7 @@ from sentry_sdk.utils import ( Components, Dsn, + get_default_release, get_error_message, get_git_revision, is_valid_sample_rate, @@ -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