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 unconvert attribute dynamodb
- dynamodb no range key value present
- DynamoDB attribute not empty
- DynamoDB scan limit not working
- DynamoDB is not showing all columns
- Dynamodb error 500
- DynamoDB BatchWriteItem error
- DynamoDB throttling error
- DynamoDB delete fails
- DynamoDB is missing the key id in the item
- DynamoDB FilterExpression not working
- DynamoDB ConditionExpression not working
- DynamoDB query is slow
- DynamoDB parameter validation failed
- DynamoDB is already installed on a path
Tired of switching accounts and regions? Use Dynobase.
Try 7-day free trial. No strings attached.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase