Skip to content

New CreateTransactWrite method enforces version check #4243

@albert-vives

Description

@albert-vives

Describe the bug

DynamoDB has undergone a lot of changes in the version 4 of the SDK, including separating the shared DynamoDBOperationConfig into new operation-specific objects (SaveConfig, LoadConfig, QueryConfig, etc.). See: #3421

The method IDynamoDBContext.CreateTransactWrite<T>(DynamoDBOperationConfig) is now marked as obsolete, and the suggested replacement is IDynamoDBContext.CreateTransactWrite<T>(TransactWriteConfig).

The new TransactWriteConfig doesn't have property SkipVersionCheck that the generic config class has, forcing it to have the default value false. This can cause conditional checks to fail when executing the transaction.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

Creating a transact write with disabled version check should be possible:

var updateTransaction = dbContext.CreateTransactWrite<Entity>(new TransactWriteConfig
{
    SkipVersionCheck = true
});

Current Behavior

The SkipVersionCheck property is not available:

var transaction = dbContext.CreateTransactWrite<Entity>(new TransactWriteConfig
{
    SkipVersionCheck = true // <-- Error
});

Using the obsolete method works:

var transaction = dbContext.CreateTransactWrite<Entity>(new DynamoDBOperationConfig
{
    SkipVersionCheck = true
}); // <-- Warning method obsolete

transaction.AddSaveItem(entity);

await transaction.ExecuteAsync(ct); // <-- Works

Reproduction Steps

var transaction = dbContext.CreateTransactWrite<Entity>();

transaction.AddSaveItem(entity); // <-- Item with wrong version

await transaction.ExecuteAsync(ct); // <-- Throws TransactionCanceledException with reason ConditionalCheckFailed

Possible Solution

Add the property SkipVersionCheck to the TransactWriteConfig class, and map it to the property with the same name in the method TransactWriteConfig.ToDynamoDBOperationConfig().

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

AWSSDK.DynamoDBv2 4.0.10.4

Targeted .NET Platform

.NET Core 8

Operating System and version

Windows 11, AWS Lambda

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.dynamodbp1This is a high priority issuepr/needs-reviewThis PR needs a review from a Member.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions