Skip to content

DynamoDBDocumentClient does not unmarshall attributes on ConditionalCheckFailedException #6723

@brianle1301

Description

@brianle1301

Checkboxes for prior research

Describe the bug

When using the document client and setting ReturnValuesOnConditionCheckFailure: 'ALL_OLD', item attributes returned with ConditionalCheckFailedException are not unmarshalled

Regression Issue

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

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

v22.3.0

Reproduction Steps

Run the snippet below against a record that violates the condition expression, using your own values and attribute names if needed.

const client = DynamoDBDocumentClient.from(new DynamoDBClient());
try {
    const result = client.send(
        new UpdateCommand({
            TableName: 'MyTable',
            Key: { pk: 'pk', sk: 'sk' },
            UpdateExpression: 'SET my_attribute = :attr',
            ConditionExpression: 'attribute_exists(pk) AND owner_id = :ownerId',
            ExpressionAttributeValues: { ':attr': 'test', ':ownerId': 'ownerId' },
            ReturnValues: 'ALL_NEW',
            ReturnValuesOnConditionCheckFailure: 'ALL_OLD',
        }),
    );
} catch (error) {
    if (error instanceof ConditionalCheckFailedException) {
        console.log(error.Item); // error.Item is unmarshalled
    }
}

Observed Behavior

The record item returned along with the error is not unmarshalled

Expected Behavior

The record item returned along with the error should be unmarshalled

Possible Solution

Catch the error, unmarshall the item and rethrow

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions