-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK reject update for item: The provided key element does not match the schema #4238
Comments
Additional context |
I got, but I received another erro not mapped/documented:
|
|
The final code is: package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"os"
)
type Item struct {
Id string `json:"id"`
Year int `json:"year"`
Title string `json:"title"`
Plot string `json:"plot"`
}
func main() {
sess := session.Must(session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
}))
// Create DynamoDB client
svc := dynamodb.New(sess)
newItem := Item{
Year: 2021,
Title: "The Big New Movie or not",
Plot: "Nothing happens at all.",
}
newItemKey := Item{
Id: "5",
}
tableName := "movies"
newInput := &dynamodb.UpdateItemInput{
ExpressionAttributeValues: map[string]*dynamodb.AttributeValue{
":title": {
S: aws.String(newItem.Title),
},
":plot": {
S: aws.String(newItem.Plot),
},
},
Key: map[string]*dynamodb.AttributeValue{
"id": {
S: aws.String(newItemKey.Id),
},
},
ReturnValues: aws.String("UPDATED_NEW"),
TableName: aws.String(tableName),
UpdateExpression: aws.String("set title = :title, plot = :plot"),
}
_, err := svc.UpdateItem(newInput)
if err != nil {
fmt.Println("Got error calling PutItem:")
fmt.Println(err.Error())
os.Exit(1)
}
} (I reopened the issue for notice by github) |
@IgorDePaula What are the partition key and sort key for your table? |
Worked for me |
Hi, is this issue still persisting with the latest version of SDK? |
This issue has not received a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled. |
Im having that issue in @aws-sdk/client-dynamodb for NodeJS. Im trying to update an Item and no matter if I input the hash and range key correctly, it still says that the provided key element doesn't match the schema. |
Same issue when using @aws-sdk/client-dynamodb for Java |
Did u solve it now? |
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
I have a dynamoDB table with item, and I would like update this item, but I receive error :
"ValidationException: The provided key element does not match the schema
status code: 400, request id: 0D1VIOQSMD3KUQE1PALT2EST8NVV4KQNSO5AEXXXXXXXXXXXXXxxxxxx"
Version of AWS SDK for Go?
SDK v1.42.32
Version of Go (
go version
)?Go 1.6
To Reproduce (observed behavior)
Expected behavior
I expect update the item
The text was updated successfully, but these errors were encountered: