[Storage] Fixed IndexError in azure-storage-blob-changefeed when listing directory marker blobs#47555
Open
weirongw23-msft wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses an IndexError in azure-storage-blob-changefeed encountered when listing change feed segments in accounts where the idx/segments/ hierarchy includes directory marker blobs, by adding validation to skip non-segment paths.
Changes:
- Added segment-path validation to skip directory marker blobs when enumerating segment blobs.
- Added a CHANGELOG entry documenting the bug fix.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sdk/storage/azure-storage-blob-changefeed/azure/storage/blob/changefeed/_models.py | Adds _is_valid_segment_path and uses it to filter out non-segment blob paths during segment listing. |
| sdk/storage/azure-storage-blob-changefeed/CHANGELOG.md | Documents the fix under the unreleased version’s “Bugs Fixed” section. |
Comment on lines
+299
to
+304
| # A valid segment path is of the form "idx/segments/YYYY/MM/DD/HHMM/<file>". | ||
| # Directory marker blobs (e.g. "idx/segments/2026/02/20") have too few tokens to | ||
| # represent a segment and must be skipped to avoid an IndexError while parsing. | ||
| path_tokens = segment_path.split(PATH_DELIMITER) | ||
| if len(path_tokens) < 6: | ||
| return False |
| paths = self.client.list_blobs(name_starts_with=SEGMENT_COMMON_PATH + str(start_year)) | ||
| for path in paths: | ||
| yield path.name | ||
| # Skip directory marker blobs that does not conform to the expected segment path shape. |
Comment on lines
282
to
+288
| while not start_year or start_year <= cur_year: | ||
| paths = self.client.list_blobs(name_starts_with=SEGMENT_COMMON_PATH + str(start_year)) | ||
| for path in paths: | ||
| yield path.name | ||
| # Skip directory marker blobs that does not conform to the expected segment path shape. | ||
| # Azure Storage can return zero-length directory markers that are not real segment files. | ||
| if self._is_valid_segment_path(path.name): | ||
| yield path.name |
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.
No description provided.