DynamoDb: No result when trying to call DescribeTable on a table with a Global Secondary Index #50
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.
I had an issue when calling DescribeTable on a table with a global secondary index.
I traced the issue to the way that the JSON is parsed in responses. I found two oddities:
The first is that the JsonUnmarshallerContext CurrentPath seems to reverse all but the last node (stack + currentField), whilst this doesn't actually make a difference to the code because it only cares about the last level it certainly confused me when I was trying to debug what was going on!
The second is that due to the fact that the DescribeTableResponseUnmarshaller doesn't currently handle the GlobalSecondaryIndexes node because it's new, everything after that point got ignored. I traced that to the way that ObjectEnd and ArrayEnd are handled; both ArrayEnd and ObjectEnd cause the stack to be popped twice, once to remove the Object/ArrayEnd token and once to remove the propertyName that it corresponds to.
This caused an issue because it resulted in the JsonUnmarshallerContext CurrentDepth property returning 1 even though there were more depth=2 properties to come at the point the Unmarshaller was at the Object/ArrayEnd token. This caused the TableDescriptionUnmarshaller to return before it was finished.
The fix may not be the best way around this but it seemed to work for my problem, basically I set a flag to pop the 2 items off the stack at the start of the next Read operation so that the path and depth are correct when the reader is at an ObjectEnd or ArrayEnd token.
This only happens if the particular Unmarshaller doesn't handle a specific property that's returned by the API, this is obviously an issue for any part of the SDK as it could happen any time that the API is updated and returns new properties.
Apologies for the whitespace (it's late) ?w=1 ftw