Skip to content

fix: skip empty patterns in match_regex_list to prevent IndexError#6842

Open
mangodxd wants to merge 1 commit into
getsentry:masterfrom
mangodxd:fix/match-regex-list-empty-string
Open

fix: skip empty patterns in match_regex_list to prevent IndexError#6842
mangodxd wants to merge 1 commit into
getsentry:masterfrom
mangodxd:fix/match-regex-list-empty-string

Conversation

@mangodxd

Copy link
Copy Markdown

Fixes #6504

match_regex_list indexes item_matcher[-1] to check for $ suffix. When the pattern list contains an empty string, ""[-1] raises IndexError: string index out of range.

This is reachable from CeleryIntegration.exclude_beat_tasks when user configures an empty string in the pattern list.

Skip empty patterns with if not item_matcher: continue before the index check. Empty strings cannot match anything, so this is the correct behavior.

Three test cases added:

  • [""] single empty pattern → no match
  • ["", "some-string"] empty then valid → matches valid
  • ["", ""] all empty → no match

match_regex_list indexes item_matcher[-1] to check for '$' suffix.
An empty string pattern causes IndexError: string index out of range.

This is reachable from CeleryIntegration.exclude_beat_tasks when
user configures an empty string in the pattern list.

Guard with if not item_matcher: continue before the index check.

Fixes getsentry#6504
@mangodxd
mangodxd requested a review from a team as a code owner July 19, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

match_regex_list raises IndexError when a pattern list contains an empty string

1 participant