Skip to content

Resurfaced: DynamoDBDocument can't unmarshall null #4504

@adclark1

Description

@adclark1

Checkboxes for prior research

Describe the bug

If I'm not mistaken, it appears that the latest version of @aws-sdk/middleware-logger (released today) has caused the bug described in the following previously closed issues to resurface:

#3846
#4222

It's causing this error again when fetching items with null attributes using @aws-sdk/lib-dynamodb:

TypeError: Cannot read properties of null (reading 'S')

SDK version number

@aws-sdk/middleware-logger@3.287.0

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

Lambda nodejs16.x

Reproduction Steps

const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
const { DynamoDBDocumentClient, GetCommand } = require('@aws-sdk/lib-dynamodb');

const ddbClient = new DynamoDBClient();
const ddbDocClient = DynamoDBDocumentClient.from(ddbClient);

const response = await ddbDocClient.send(new GetCommand({
    TableName: 'table',
    Key: {
      pk: 'pk',
      sk: 'sk',
    },
  }));

Observed Behavior

TypeError: Cannot read properties of null (reading 'S')

{
    "errorType": "TypeError",
    "errorMessage": "Cannot read properties of null (reading 'S')",
    "stack": [
        "TypeError: Cannot read properties of null (reading 'S')",
        "    at AttributeValueFilterSensitiveLog (/var/task/test/node_modules/@aws-sdk/client-dynamodb/dist-cjs/models/models_0.js:1328:13)",
        "    at /var/task/test/node_modules/@aws-sdk/client-dynamodb/dist-cjs/models/models_0.js:1414:128",
        "    at Array.reduce (<anonymous>)",
        "    at GetItemOutputFilterSensitiveLog (/var/task/test/node_modules/@aws-sdk/client-dynamodb/dist-cjs/models/models_0.js:1414:40)",
        "    at /var/task/test/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:17:21",
        "    at processTicksAndRejections (node:internal/process/task_queues:96:5)",
        ...
    ]
}

Expected Behavior

Successful retrieval of item with a null attribute without an error being thrown.

Possible Solution

No response

Additional Information/Context

Seeing this with the latest version of @aws-sdk/client-dynamodb and @aws-sdk/lib-dynamodb being used. It appears to be the dependencies they have on @aws-sdk/middleware-logger.

Metadata

Metadata

Labels

bugThis issue is a bug.p1This is a high priority issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions