Skip to content

fix: handle empty strings in match_regex_list to prevent IndexError - #1

Draft
wahajahmed010 wants to merge 1 commit into
masterfrom
fix/6504-match-regex-list-empty-string
Draft

fix: handle empty strings in match_regex_list to prevent IndexError#1
wahajahmed010 wants to merge 1 commit into
masterfrom
fix/6504-match-regex-list-empty-string

Conversation

@wahajahmed010

Copy link
Copy Markdown
Owner

Description

When match_regex_list receives a list containing an empty string, accessing item_matcher[-1] raises IndexError: string index out of range. This is reachable from the Celery integration via CeleryIntegration.exclude_beat_tasks.

This fix skips empty strings in the iteration, matching the existing behavior of treating them as non-matching patterns.

Changes

  • sentry_sdk/utils.py: Skip empty strings in match_regex_list loop
  • tests/test_utils.py: Add test cases for empty string patterns

Issues

AI Assistance Disclosure

This contribution was developed with assistance from an AI coding agent (Buck/OpenClaw). The changes were reviewed and tested by a human before submission.

Reminders

  • Tests added/updated
  • Changes are focused on one thing
  • PR created as draft per contributing guidelines

When match_regex_list receives a list containing an empty string,
accessing item_matcher[-1] raises IndexError. This is reachable
from the Celery integration via CeleryIntegration.exclude_beat_tasks.

Skip empty strings in the iteration to handle this gracefully.

Fixes getsentry#6504

Signed-off-by: Wahaj Ahmed <wahaj.ahmed010@gmail.com>
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