-
Notifications
You must be signed in to change notification settings - Fork 634
Description
Checkboxes for prior research
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow.
- I've searched for previous similar issues and didn't find any solution.
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
aws-sdk-js-v3/lib/lib-dynamodb/src/DynamoDBDocumentClient.ts
Lines 144 to 145 in de4dc49
| 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