Error: ValidationException: Invalid KeyConditionExpression: Attribute name is a reserved keyword;

Answered by Rafal Wilinski
Solution
DynamoDB has a list of reserved keywords that you cannot use in your queries or scans directly. If you need to write an expression that contains one of them, you need to use ExpressionAttributeNames to replace reserved word with a placeholder. For example, this query with reserved keyword:
params = { TableName : ‘MY_TABLE’, FilterExpression: "timestamp BETWEEN :startDate AND :endDate", ExpressionAttributeValues: { ":startDate": ""+startDate, ":endDate": ""+endDate } }
Replace with:
params = { TableName : ‘MY_TABLE’, FilterExpression: "#dynobase_timestamp BETWEEN :startDate AND :endDate", ExpressionAttributeValues: { ":startDate": startDate, ":endDate": endDate }, ExpressionAttributeNames: { "#dynobase_timestamp": "timestamp" } }
Other Common DynamoDB Errors (with Solutions)
- DynamoDB Query Limit Not Working
- dynamodb local unable to open database file
- DynamoDB is already installed on a path
- DynamoDB local error spawn java ENOENT
- dynamodb unknown error
- DynamoDB throttling error
- DynamoDB query is slow
- DynamoDB table not updating
- DynamoDB consistent read not working
- DynamoDB ConditionExpression not working
- DynamoDB is missing the key id in the item
- DynamoDB local error unable to access JAR file dynamodblocal.jar
- DynamoDB scan does not return all items
- dynamodb value cannot be null. (parameter 'type')
- DynamoDB GetItem no item
Dynobase is a Professional GUI Client for DynamoDB
Start your 7-day free trial today
Product Features
DynamoDB Tools
DynamoDB Info
© 2025 Dynobase