Skip to content

DyanmoDB (UpdateTable) - SerializationException: Start of structure or map found where not expected #7102

@fishcharlie

Description

@fishcharlie

Checkboxes for prior research

Describe the bug

SerializationException: Start of structure or map found where not expected error when trying to run UpdateTable in AWS SDK JS.

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.14.0

Reproduction Steps

const tableName = 'User-1748112703761';
const { DynamoDBClient, CreateTableCommand, CreateGlobalTableCommand, UpdateTableCommand } = require('@aws-sdk/client-dynamodb');
const client = new DynamoDBClient({ region: 'us-west-2' });

const createTableCommand = new CreateTableCommand({
    TableName: tableName,
    BillingMode: 'PAY_PER_REQUEST',
    AttributeDefinitions: [ { AttributeName: 'id', AttributeType: 'S' } ],
    KeySchema: [ { AttributeName: 'id', KeyType: 'HASH' } ],
    StreamSpecification: { StreamEnabled: true, StreamViewType: 'NEW_AND_OLD_IMAGES' },
});
await client.send(createTableCommand);

await waitForTableActive(client, tableName);

const updateTableCommand = new UpdateTableCommand({
    TableName: tableName,
    ReplicaUpdates: {
        Create: [ { RegionName: 'us-west-1' } ]
    }
});
await client.send(updateTableCommand); // This seems to be the line that is failing. If I comment this out it works fine.

// Just a helper function to wait for the table to be active. Not critical to the problem.
async function waitForTableActive(client, tableName) {
    const { DynamoDBClient, DescribeTableCommand } = require('@aws-sdk/client-dynamodb');

    let tableStatus = 'CREATING';
    while (tableStatus !== 'ACTIVE') {
        await new Promise(resolve => setTimeout(resolve, 5000)); // Wait 5 seconds

        const describeCommand = new DescribeTableCommand({ TableName: tableName });
        const response = await client.send(describeCommand);
        tableStatus = response.Table.TableStatus;

        console.log(`Table status: ${tableStatus}`);
    }
}

Observed Behavior

/Users/charliefish/tmp2/node_modules/@aws-sdk/smithy-client/dist-cjs/default-error-handler.js:8
const response = new exceptionCtor({
^

SerializationException: Start of structure or map found where not expected
at throwDefaultError (/Users/charliefish/tmp2/node_modules/@aws-sdk/smithy-client/dist-cjs/default-error-handler.js:8:22)
at /Users/charliefish/tmp2/node_modules/@aws-sdk/smithy-client/dist-cjs/default-error-handler.js:18:39
at de_UpdateTableCommandError (/Users/charliefish/tmp2/node_modules/@aws-sdk/client-dynamodb/dist-cjs/protocols/Aws_json1_0.js:2556:20)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async /Users/charliefish/tmp2/node_modules/@aws-sdk/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24
at async /Users/charliefish/tmp2/node_modules/@aws-sdk/middleware-signing/dist-cjs/middleware.js:14:20
at async /Users/charliefish/tmp2/node_modules/@aws-sdk/middleware-retry/dist-cjs/retryMiddleware.js:27:46
at async /Users/charliefish/tmp2/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26
at async /Users/charliefish/tmp2/index.js:56:2 {
'$fault': 'client',
'$metadata': {
httpStatusCode: 400,
requestId: 'T4LD9197GUUNAJQQ238H5KJK9NVV4KQNSO5AEMVJF66Q9ASUAAJG',
extendedRequestId: undefined,
cfId: undefined,
attempts: 1,
totalRetryDelay: 0
},
__type: 'com.amazon.coral.service#SerializationException'

Expected Behavior

It to complete without throwing an error

Possible Solution

No response

Additional Information/Context

aws-vault exec root -- aws dynamodb update-table --table-name User-1748112703761 --cli-input-json  \
'{
  "ReplicaUpdates":
  [
    {
      "Create": {
        "RegionName": "us-west-1"
      }
    }
  ]
}' \
--region=us-west-2

^ this code seems to have worked if I run this in terminal. It just fails when using AWS SDK JS.

Metadata

Metadata

Assignees

Labels

closed-for-stalenessguidanceGeneral information and guidance, answers to FAQs, or recommended best practices/resources.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions