Fix S3 glob XML parsing to ignore non-Contents nodes (e.g. Marker)#350
Open
cbardasano wants to merge 1 commit intoconnormanning:masterfrom
Open
Fix S3 glob XML parsing to ignore non-Contents nodes (e.g. Marker)#350cbardasano wants to merge 1 commit intoconnormanning:masterfrom
cbardasano wants to merge 1 commit intoconnormanning:masterfrom
Conversation
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.
Summary
This PR fixes a bug in
S3::globwhere the XML parsing loop incorrectly assumes that all sibling nodes following the first<Contents>node are also<Contents>nodes.The Issue
When using S3-compatible storage providers (specifically Digital Ocean Spaces in my case), the
ListBucketResultXML response may contain additional nodes like<Marker>appearing after the last<Contents>node.The current implementation uses
conNode = conNode->next_sibling()without arguments. This causes the loop to iterate over these non-Contentsnodes. Since<Marker>(and probably others) do not contain a<Key>child, the function throws anArbiterError("Missing Key...").Example of crashing XML response:
The Fix
I updated the loop to explicitly request the next sibling with the name "Contents":
This ensures that
RapidXMLskips any sibling nodes that are not<Contents>, preventing the crash on valid S3 responses that include metadata like markers at the end of the list.