getsentry / getsentry/sentry-python

match_regex_list raises IndexError when a pattern list contains an empty string

Open
#6,504 1 comment 0 reactions 0 assignees View on GitHub
Bug Python
Dominant language
Python
Stars
2.2k
Forks
669
Avg merge
1d 40m
Merged PRs (30d)
212

Description

`sentry_sdk.utils.match_regex_list` iterates a user-supplied list of patterns and, with the default `substring_matching=False`, checks `item_matcher[-1] != "$"`. If any element is the empty string, `""[-1]` raises `IndexError: string index out of range`.

```python
from sentry_sdk.utils import match_regex_list
match_regex_list("anything", [""])
```

This is reachable from the Celery integration (`CeleryIntegration.exclude_beat_tasks` is passed to `match_regex_list` with the default mode), so an empty string in that user-configured list crashes instead of being handled.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.