Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Dynamodb KeyConditionExpression use gives ValidationException #3528

@joe94

Description

@joe94

Confirm by changing [ ] to [x] below to ensure that it's a bug:

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

No one assigned

    Labels

    guidanceQuestion that needs advice or information.service-apiThis issue is due to a problem in a service API, not the SDK implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions