fix: handle empty strings in match_regex_list to prevent IndexError - #1
Draft
wahajahmed010 wants to merge 1 commit into
Draft
fix: handle empty strings in match_regex_list to prevent IndexError#1wahajahmed010 wants to merge 1 commit into
wahajahmed010 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When
match_regex_listreceives a list containing an empty string, accessingitem_matcher[-1]raisesIndexError: string index out of range. This is reachable from the Celery integration viaCeleryIntegration.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 inmatch_regex_listlooptests/test_utils.py: Add test cases for empty string patternsIssues
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