Description
Describe the bug
If the item passed into Amazon.DynamoDBv2.AmazonDynamoDBClient.PutItemAsync
method contains an AttributeValue
with a self-reference, the method call results in a StackOverflowException. Since this exception cannot be caught, I assume it will crash whatever runtime environment the code is running in.
Regression Issue
- Select this option if this issue appears to be a regression.
Expected Behavior
The call results in AmazonDynamoDBException or one of its inheritors.
Current Behavior
A StackOverflowException is thrown. Please, see the stack trace in ExceptionStack.txt
attached. Note that the stack trace has been shortened for readability, because it contained a lot of identical AttributeValueMarshaller.Marshall
calls.
Reproduction Steps
Assuming that we have a DynamoDB table with a numeric hash key attribute called Id
:
using Amazon.DynamoDBv2;
using Amazon.DynamoDBv2.Model;
using var dynamoDbClient = new AmazonDynamoDBClient();
// An attribute value with a self-reference
var badItem = new Dictionary<string, AttributeValue>();
badItem["C"] = new AttributeValue { M = badItem };
var request = new PutItemRequest
{
TableName = "<Table name here>",
Item = new Dictionary<string, AttributeValue>
{
["Id"] = new AttributeValue { N = "1" },
["Data"] = new AttributeValue { M = badItem }
}
};
await dynamoDbClient.PutItemAsync(request);
Possible Solution
No response
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.DynamoDBv2 3.7.406.7
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11