From 1ec1ee569efcdaaf765b05e6cce4c808be6a6f01 Mon Sep 17 00:00:00 2001 From: hiro-nikaitou Date: Mon, 13 Jul 2026 09:30:47 +0800 Subject: [PATCH] fix(match_regex_list): handle empty string patterns without IndexError An empty string pattern in the regex list causes IndexError when accessing item_matcher[-1]. Skip empty string patterns in the loop to prevent the crash. Closes #6504 --- sentry_sdk/utils.py | 2 ++ tests/test_utils.py | 1 + 2 files changed, 3 insertions(+) diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index 0963015351..8a67ec1d77 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -1736,6 +1736,8 @@ def match_regex_list( return False for item_matcher in regex_list: + if item_matcher == "": + continue if not substring_matching and item_matcher[-1] != "$": item_matcher += "$" diff --git a/tests/test_utils.py b/tests/test_utils.py index 718cdbaa1d..5a67fe8429 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -551,6 +551,7 @@ def test_include_source_context_when_serializing_frame(include_source_context): ["some-string", [], False], ["some-string", None, False], ["some-string", ["some-string"], True], + ["some-string", [""], False], ["some-string", ["some"], False], ["some-string", ["some$"], False], # same as above ["some-string", ["some.*"], True],