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

Answered by Rafal Wilinski
What's Causing This Error
This error occurs when you have used expression attribute names for the KeyConditionExpression
or FilterExpression
that are not defined in the ExpressionAttributeNames
parameter.
Solution - Here's How To Resolve It
To resolve the error, define all the expression attribute names you've specified for the document paths in the ExpressionAttributeNames
object.
This is shown below.
const doFunStuff = async () => { await documentClient.query({ TableName: 'test-table', KeyConditionExpression: '#id = :id', ProjectionExpression: '#name', // define all the expression attribute names used in the query ExpressionAttributeNames: { '#id': 'id', '#name': 'name' }, ExpressionAttributeValues: { ':id': '1' }, }).promise(); }; doFunStuff();
Other Common DynamoDB Errors (with Solutions)
- could not load profile default dynamodb
- DynamoDB Duplicate Key Error
- why is the GSI dynamodb not showing item count
- dynamodb docker unable to open database file
- dynamodb list_append returns true but does not work
- dynamodb could not load credentials from any providers
- dynamodb list_append if_not_exists not working
- ValidationException: Invalid KeyConditionExpression: Attribute name is a reserved keyword;
- dynamodb localhost error
- error updating dynamodb table time to live
- DynamoDB parameter validation failed
- dynamodb the table does not have the specified index
- comparison operator does not return all attributes dynamodb
- dynamodb cannot read properties of undefined
- AWS DynamoDB CredentialsError: Missing credentials in config
Spend less time in the AWS console, use Dynobase.
Try 7-day free trial. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase