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)
- dynamodb the parameter cannot be converted to a numeric value NaN
- sls dynamodb install not working
- could not connect to the endpoint URL dynamodb
- DynamoDB ValidationException: Query condition missed key schema element
- DynamoDB TTL Not Working
- name key is not defined dynamodb
- dynamodb getItem() is not a function
- DynamoDB Errors InvalidSignatureException Signature Expired
- dynamodb list_append if_not_exists not working
- accessdeniedexception dynamodb
- dynamodb index does not exist
- error dynamodb streams must be enabled on the table
- DynamoDB Local Cannot Create Preexisting Table
- dynamodb unable to execute http request
- Could not connect to the endpoint URL https:dynamodb.singapore.amazonaws.com
Spend less time in the AWS console, use Dynobase.
First 7 days are. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase