From 64c42ca975b804b0277643a761df099717d10253 Mon Sep 17 00:00:00 2001 From: Ivana Kellyerova Date: Wed, 13 Dec 2023 13:15:15 +0100 Subject: [PATCH] fix(utils): Filter out empty string releases (#2591) Instead of only allowing truthy releases, we were allowing all non-`None` releases, which includes empty strings. --- sentry_sdk/utils.py | 2 +- tests/test_utils.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) 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