1

I'm trying to do a simple transactional 'move' of data from one table to another in DynamoDB (to add indexes). Here's the call I'm making, the promise is returned because I'm using .then() to interpret it, but as you can see from the result I'm getting back there's something wrong with my JSON. Unfortunately, the error message is not very helpful. Very grateful of any help.

var runner = async (column1Value, column2Value) => {
  return await ddb.transactWriteItems({
    TransactItems: [
      {
        Delete: {
          TableName: 'TABLE_V2',
          Key: {
            AuthorName: {
              S: column1Value
            }
          }
        }
      }
      ,
      {
        Put: {
          Item: {
            'AuthorName': {
              S: column1Value
            },
            'AuthorTitle': {
              S: column2Value
            }
          },
          TableName: 'TABLE_V3'
        }
      }
    ]
  }).promise();
}

When I run my code I get the following:

    at Request.extractError...
  message: 'Transaction cancelled, please refer cancellation reasons for specific reasons [ValidationError, None]',
  code: 'TransactionCanceledException',
  time: 2019-03-31T00:03:05.401Z,
  requestId: 'URIARNJDVFHDVLQQNR1JMIJP5NVV4KQNSO5AEMVJF66Q9ASUAAJG',
  statusCode: 400,
  retryable: false,
  retryDelay: 30.057548210067033

I've read a few sites out there but all refer to a time froms before DynamoDB natively supported transactions with the .transactWriteItems(). e.g.: How to support transactions in dynamoDB with javascript aws-sdk?

1 Answer 1

2

Ok, so, there were two issues (let me know if they are not relevant to this site).

  1. The 'Put' error was being thrown by the fact that there was a space character after the column name for the first column: 'AuthorName '
  2. The 'Delete' error was being thrown by the fact that the TABLE_V2 is using not just a primary key but a search key also, so its JSON needs to be:
Delete: {
  TableName: 'TABLE_V2',
  Key: {
    AuthorName: {
      S: column1Value
    },
    AuthorTitle: {
      S: column2Value
    }
  }
}
1
  • Feel free to accept your own answer if that’s what fixed your problem. Commented Apr 2, 2019 at 10:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.