Skip to content

Conversation

@dscpinheiro
Copy link
Contributor

Fixes #3802

Motivation and Context

Fixes a regression introduced in V4 where an expression without variables would throw an AmazonDynamoDBException: ExpressionAttributeValues must not be empty. For example, this operation:

var ddb = new AmazonDynamoDBClient();
var table = new TableBuilder(ddb, "TestTable").AddHashKey("pk", DynamoDBEntryType.String).Build();
var doc = new Document { ["pk"] = Guid.NewGuid().ToString() };

await table.PutItemAsync(doc, new PutItemOperationConfig
{
    ConditionalExpression = new Expression { ExpressionStatement = "attribute_not_exists(pk)" },
});

Would result in the following request body:

{"ConditionExpression":"attribute_not_exists(pk)","ExpressionAttributeValues":{},"Item":{"pk":{"S":"386ba1d5-5b18-47e5-9c22-3b73e0f1ddd1"}},"TableName":"TestTable"}

This PR updates the document model to match the request sent by V3:

{"ConditionExpression":"attribute_not_exists(pk)","Item":{"pk":{"S":"75fbb295-a11c-4447-ac1a-bacc2baacd0c"}},"TableName":"TestTable"}

Testing

  • Dry-run: DRY_RUN-c628983c-fa45-42c4-a4d0-81921c146e4f
  • Also confirmed this works when AWSConfigs.InitializeCollections is set to true

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • My code follows the code style of this project
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

@dscpinheiro dscpinheiro requested a review from normj May 9, 2025 19:02
@dscpinheiro dscpinheiro added the v4 label May 9, 2025
@boblodgett boblodgett merged commit f558b40 into development May 12, 2025
1 check passed
@dscpinheiro dscpinheiro deleted the dspin/gh-3802 branch May 25, 2025 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamoDB Exception: ExpressionAttributeValues must not be empty, even when there are no variables

3 participants