Skip to content

DynamoDBDocumentClients override other DynamoDBDocumentClients' marshalling options #6545

@misterjoshua

Description

@misterjoshua

Checkboxes for prior research

Describe the bug

When you're sharing one DynamoDBClient between multiple DynamoDBDocumentClients, the marshalling options from the most recently created document client overwrites all the other document clients' marshalling options.

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

Node 20.13.1

Reproduction Steps

test('error', async () => {
  const sharedClient = new DynamoDBClient();

  const doc1 = DynamoDBDocumentClient.from(sharedClient, {
    marshallOptions: {
      convertEmptyValues: true,
      removeUndefinedValues: true,
    },
  });

  const doc2 = DynamoDBDocumentClient.from(sharedClient, {
    marshallOptions: {
      convertEmptyValues: false,
      removeUndefinedValues: false,
    },
  });

  expect(doc1.config.translateConfig?.marshallOptions?.removeUndefinedValues).toBe(true);
  expect(doc1.config.translateConfig?.marshallOptions?.convertEmptyValues).toBe(true);
});

Observed Behavior

The first document client's marshallOptions were overwritten by the second's marshallOptions.

Expected Behavior

Each document client's options should be distinct and should not affect each other even if they're sharing a DynamoDBClient.

Possible Solution

this.config = client.config;
this.config.translateConfig = translateConfig;

DynamoDBDocumentClient is sharing and mutating the underlying DynamoDBClient's config object when it should be keeping a private copy of the translate config.

Additional Information/Context

No response

Metadata

Metadata

Labels

bugThis issue is a bug.p2This is a standard priority issuequeuedThis issues is on the AWS team's backlog

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions