AWS Error: One of the required keys was not given a value.
See original GitHub issueI have a weird error regarding getting data with dynamoose. What I do is using objectmodel to define/validate my models. I can put/save elements via dynamoose to dynamodb but when trying to get an object an error occurs.
var db = require("dynamoose");
var get = function(table, object) {
return db.model(table, object.constructor.definition).get(object.id);
};
var put = function(table, object) {
var model = db.model(table, object.constructor.definition);
var newObj = new model(object);
return newObj.save();
};
So I have a test file to first put data to dynamodb and after that get that data. I can see the data is written to dynamodb with the put-function but when I try to get it with the get-function the error is the following, even if the definition file is exactly the same.
{
"message": "One of the required keys was not given a value",
"code": "ValidationException",
"time": "2017-02-24T21:42:10.423Z",
"requestId": "5f10ff0c-e889-41d1-8992-8e0480bd27fb",
"statusCode": 400,
"retryable": false,
"retryDelay": 0
}
Any idea on this?
Current definition file of objectmodel (object.constructor.definition):
{
address:
{ company: [ [Function: String] ],
name: [Function: String],
street: [Function: String],
zip: [Function: String],
city: [Function: String],
country: [Function: String] },
id: [Function: String]
}
Definition File for DynamoDB which I use to create the table. id is my key at the moment:
{
"TableName": "customers",
"KeySchema": [{
"AttributeName": "id",
"KeyType": "HASH"
}],
"AttributeDefinitions": [{
"AttributeName": "id",
"AttributeType": "S"
}],
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
}
}
Picture of Local Test Environment:
hashKey equals the id which I pass in get-function via object.id and ObjectJSON is the Data I wrote to db.
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (5 by maintainers)
Top Related StackOverflow Question
Hi
I have the same issue with the following configuration
and this method to save the company
with the following error:
I run into the same issue and after a few hours trying to figure out what is going on I found out. This was due to the table being initially created with a certain schema, mine was set to expect a hash attribute of “cardId” then changed to “id” so it was throwing the “ValidationException”
To check what is in the table KeySchema use NoSQL Workbench, go to the table and click on the Metadata tab.
To resolve the issue just delete and create the table again.