dynobase-icon
Dynobase

Error: dynamodb cannot read properties of undefined

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

Cannot read properties of undefined is a JavaScript TypeError, not a DynamoDB service exception. The stack trace identifies which object was missing when your code tried to read a property.

import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, QueryCommand } from "@aws-sdk/lib-dynamodb";

const db = DynamoDBDocumentClient.from(new DynamoDBClient({}));

const response = await db.send(new QueryCommand({
  TableName: "Orders",
  KeyConditionExpression: "pk = :pk",
  ExpressionAttributeValues: { ":pk": "CUSTOMER#123" },
}));
const first = response.Items?.[0];
if (first === undefined) {
  console.log("No item on this page");
} else {
  console.log(first.sk);
}

Defaulting Items to [] does not make Items[0] exist. A filtered page can be empty while LastEvaluatedKey indicates more pages. GetCommand returns a single optional Item, not Items. Check projections when a nested property is missing from an otherwise valid item.

Await the request and do not swallow SDK failures and then continue with an undefined result. Optional chaining is useful when absence is expected; otherwise validate the data and report the unexpected shape rather than hiding the bug.

See JavaScript examples and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Pricing
/
Member Portal
/
Privacy
/
EULA
/
Twitter
© 2026 Dynobase
+
Still using AWS DynamoDB Console?
Try Dynobase to accelerate your DynamoDB workflow. Start your 7-day free trial today.