aws/aws-sdk-net — pull request #50 by IainCole (2013-12-12 21:19:12+00:00)
Title: DynamoDb: No result when trying to call DescribeTable on a table with a Global Secondary Index

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