diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index 875d28c0d0..49ee719582 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -1740,6 +1740,9 @@ def match_regex_list( return False for item_matcher in regex_list: + if not item_matcher: + return False + if not substring_matching and item_matcher[-1] != "$": item_matcher += "$" diff --git a/tests/test_utils.py b/tests/test_utils.py index 718cdbaa1d..530d6ab41a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -556,6 +556,7 @@ def test_include_source_context_when_serializing_frame(include_source_context): ["some-string", ["some.*"], True], ["some-string", ["Some"], False], # we do case sensitive matching ["some-string", [".*string$"], True], + ["some-string", [""], False], # an empty-string pattern is treated like [] ], ) def test_match_regex_list(item, regex_list, expected_result):