Skip to content

Dynamodb KeyConditionExpression use gives ValidationException #4345

Answered by kevinmichaelchen
joe94 asked this question in Q&A
Discussion options

You must be logged in to vote

I was getting a similar ValidationException with expression.NewBuilder. Ultimately, what was causing the error on my end was using the QueryInput.IndexName field (not sure why).

Here's what worked for me:

cond, err := expression.NewBuilder().
	WithKeyCondition(expression.Key("bucket").Equal(expression.Value(bucket))).
	Build()

// handle error

q := dynamodb.QueryInput{
	TableName: aws.String("my-buckets-table"),
	// TODO this line is problematic, since we get the error:
	//  failed to query data: ValidationException: The table does not have the specified index: bucket
	//IndexName:                 aws.String("bucket"),
	KeyConditionExpression:    cond.KeyCondition(),
	ExpressionAttribute…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vudh1
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
guidance Question that needs advice or information. service-api This issue is due to a problem in a service API, not the SDK implementation.
2 participants
Converted from issue

This discussion was converted from issue #3528 on April 01, 2022 17:38.