dynobase-icon
Dynobase

Error: dynamodb list_append if_not_exists not working

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

list_append(if_not_exists(...)) supplies a default for a missing list, but it does not create missing parent maps. Updating parent.child fails if parent is absent or is not a Map.

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

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

const result = await db.send(new UpdateCommand({
  TableName: "Records",
  Key: { pk: "record-1" },
  UpdateExpression: "SET #items = list_append(if_not_exists(#items, :empty), :new)",
  ExpressionAttributeNames: { "#items": "items" },
  ExpressionAttributeValues: { ":empty": [], ":new": [{ name: "Jake" }] },
  ReturnValues: "ALL_NEW",
}));

This top-level list needs no parent map. For a nested list, create the parent map when the item is created, or initialize it in a separate conditional update before appending. Do not set both parent and parent.child in the same expression: their paths overlap. Account for another writer deleting or changing the parent between separate operations.

Both arguments to list_append must be Lists. if_not_exists does not replace an existing NULL or a value of the wrong type. The function name is list_append, not list_appends, and each alias and value placeholder must be defined.

See update examples and AWS documentation.

Dynobase is a Professional GUI Client for DynamoDB

Start your 7-day free trial today

Product Features

Download
/
Changelog
/
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.