dynobase-icon
Dynobase

Error: an expression attribute name used in the document path is not defined

Rafal Wilinski

Answered by Rafal Wilinski

Last updated: October 23rd, 2026

Solution

This error means an expression contains a #name alias that is absent from ExpressionAttributeNames. The map must cover aliases in every expression in the request, not just the key condition.

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

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

const result = await db.send(new QueryCommand({
  TableName: "Users",
  KeyConditionExpression: "#id = :id",
  ProjectionExpression: "#profile.#name",
  ExpressionAttributeNames: {
    "#id": "id", "#profile": "profile", "#name": "name",
  },
  ExpressionAttributeValues: { ":id": "user-1" },
}));

The nested path #profile.#name needs two aliases. Mapping a single alias to profile.name refers to an attribute literally named profile.name instead. Check capitalization, accidental map overwrites when composing request objects, and the distinction between #name aliases and :value placeholders. Remove alias definitions that no expression uses.

See expression aliases 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.