TransactWriteItems API fails for an update group larger than 10 in number. Error: Member must have length less than or equal to 10

Viewed 3082

Problem TransactWriteItems API throws the below error for an update group larger than 10 in number even though the API is expected to work up to 25.

As per the AWS TransactWriteItems API Documentation:

TransactWriteItems is a synchronous write operation that groups up to 25 action requests. These actions can target items in different tables, but not in different AWS accounts or Regions, and no two actions can target the same item. For example, you cannot both ConditionCheck and Update the same item. The aggregate size of the items in the transaction cannot exceed 4 MB.

Version of AWS SDK

"aws-sdk": "^2.624.0"

Error

message: 'Member must have length less than or equal to 10',
code: 'ValidationException',
time: 2020-02-24T05:07:02.795Z,
requestId: 'a3952ab2-593e-4164-ad2f-3a000e599cia',
statusCode: 400,
retryable: false,
retryDelay: 48.36097368479314 } 
'ValidationException*: Member must have length less than or equal to 10 at Request.extractError (node_modules/aws-sdk/lib/protocol/json.js:51:27)\n    at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:106:20)\n    at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:78:10)\n    at Request.emit (node_modules/aws-sdk/lib/request.js:683:14)\n    at Request.transition (node_modules/aws-sdk/lib/request.js:22:10)\n    at AcceptorStateMachine.runTo (node_modules/aws-sdk/lib/state_machine.js:14:12)\n    at node_modules/aws-sdk/lib/state_machine.js:26:10\n    at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:38:9)\n    at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:685:12)\n    at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:116:18)'

Code:

var AWS = require('aws-sdk');
var dynamodb = new AWS.DynamoDB({
    'region': 'eu-west-1'
});

// Throws the error if the TransactItems array is > 10
var params = {
    TransactItems: [{
        Update: {
            Key: { "id": { "S": "ABC-XYABV2-2019" }},
            ExpressionAttributeNames: { "#s": "s" },
            ExpressionAttributeValues: { ":s": { "S": "OHIO" } },
            UpdateExpression: "SET #s = :s",
            TableName: "test-order-dev"
        }
    }, 
    ...
    ....
    .....
    {
        Update: {
            Key: { "id": { "S": "CDE-ZUABV2-2020" }},
            ExpressionAttributeNames: { "#s": "s" },
            ExpressionAttributeValues: { ":s": { "S": "OHIO" } },
            UpdateExpression: "SET #s = :s",
            TableName: "test-order-dev"
        }
    }
]
};
dynamodb.transactWriteItems(params, function (err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data); // successful response
});

I just found one AWS Forum link that describes the same issue and hints to use the latest SDK version. I'm at the latest SDK version, wondering what could be the issue. Share your thoughts or solution if it exists :-)

1 Answers

I was facing this issue yesterday while updating more than 10 rows using transactions. I found it an issue with my local dynamodb which I installed using docker pull amazon/dynamodb-local. It worked well with 25 max transactions while using the online DB. Hope this helps.

Related