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 Network Error: self signed certificate in chain
- dynamodb atomic counter not working
- AWS Lambda DynamoDB Stream Error
- DynamoDB ValidationException: Query condition missed key schema element
- dynamodb put item not working
- Boto3 DynamoDB KeyError
- DynamoDB Scan Not Working
- dynamodb converter not found for enhancedtype
- failed to begin subsegment named 'amazondynamodbv2': segment cannot be found.
- Float types are not supported. Use decimal types instead.
- com amazonaws services dynamodbv2 model resourcenotfoundexception
- dynamodb cannot read property 'push' of undefined
- boto3 dynamodb unable to locate credentials
- dynamodb mapper save not persisting
- aws.dynamodb.converter.unmarshall not working
Tired of AWS Console? Try Dynobase.
First 7 days are. No credit card needed.
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase