This repository was archived by the owner on Jul 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
Dynamodb KeyConditionExpression use gives ValidationException #3528
Copy link
Copy link
Closed
Labels
guidanceQuestion that needs advice or information.Question that needs advice or information.service-apiThis issue is due to a problem in a service API, not the SDK implementation.This issue is due to a problem in a service API, not the SDK implementation.
Description
Confirm by changing [ ] to [x] below to ensure that it's a bug:
- I've gone through Developer Guide and API reference
- I've checked AWS Forums and StackOverflow for answers
- I've searched for previous similar issues and didn't find any solution
Describe the bug
Error Seen migrating Query() calls from KeyConditions to KeyConditionExpressions
Version of AWS SDK for Go?
1.34.19
Version of Go (go version)?
go1.14.3
To Reproduce (observed behavior)
This is the original code fragment that works fine:
queryResult, err := d.c.Query(&dynamodb.QueryInput{
TableName: aws.String(d.tableName),
KeyConditions: map[string]*dynamodb.Condition{
"bucket": {
ComparisonOperator: aws.String("EQ"),
AttributeValueList: []*dynamodb.AttributeValue{
{
S: &bucket,
},
},
},
},
ReturnConsumedCapacity: aws.String(dynamodb.ReturnConsumedCapacityTotal),
})
Then following the instructions here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.KeyConditions.html
I wrote the following which at runtime throws a validationException.
queryResult, err := d.c.Query(&dynamodb.QueryInput{
TableName: aws.String(d.tableName),
KeyConditionExpression: aws.String("bucket = :b"),
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
"b": {
S: &bucket,
},
},
ReturnConsumedCapacity: aws.String(dynamodb.ReturnConsumedCapacityTotal),
})
Expected behavior
I wanted the behavior to match that of the legacy functions.
Additional context
bucket is a partitionKey.
Metadata
Metadata
Assignees
Labels
guidanceQuestion that needs advice or information.Question that needs advice or information.service-apiThis issue is due to a problem in a service API, not the SDK implementation.This issue is due to a problem in a service API, not the SDK implementation.