DynamoDB putItem Validation Error: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes

See original GitHub issue

Here is my code:

    obj = _.chain(obj)
    .values()
    .map(function(item) {
        return item ? item.toString() : "";
    })
    .value();

    DynamoDB.putItem({
        "TableName": tblName,
        "Item": {
            "UserId": { "S": obj.user_id },
            "Identifier": { "S": obj.identifier },
            "ReferralToken": { "S": obj.referral_token },
            "CampaignId": { "S": obj.campaign_id },
            "FirstName": { "S": obj.first_name },
            "LastName": { "S": obj.last_name },
            "Gender": { "S": obj.gender },
            "BirthDate": { "S": obj.birthdate },
            "Username": { "S": obj.username },
            "MobileNumber": { "S": obj.mobile_number },
            "PostalCodeText": { "S": obj.postal_code_text },
            "Classification": { "S": obj.classification },
            "DeliveryEmail": { "S": obj.delivery_email },
            "DeliverySMS": { "S": obj.delivery_sms }
        }
    }, function (err, data) {
        console.log(err);
        console.log(data);
    });

The error I keep getting is:

{ [ValidationException: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes]
  message: 'Supplied AttributeValue is empty, must contain exactly one of the supported datatypes',
  code: 'ValidationException',
  time: Fri Oct 10 2014 11:04:00 GMT-0500 (CDT),
  statusCode: 400,
  retryable: false }

I am sure I am doing something obviously wrong, I just can’t seem to figure out what’s wrong

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
lsegalcommented, Oct 10, 2014

@dennismonsewicz the DynamoDB API does not allow empty strings for items, see here (search for “empty string”). Your code that replaces items with “” is likely what is causing the error.

If you really want to store those empty objects, you might consider using the new NULL type in DynamoDB just released this week, though that would require passing (and parsing) { NULL: true } instead of { S: ... }. You might also want to look at awslabs/dynamodb-document-js-sdk which supports converting null values in a more transparent way using the new NULL types.

4reactions
dennismonsewiczcommented, Oct 11, 2014

Thanks so much for the help! I think I figured out my issue.

It appears even if you label an item as an N type, you have to convert it the item to a string. So your object mapping would look like…

{ "N": "1234" }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Supplied AttributeValue is empty, must contain exactly one of ...
Attribute values cannot be null. String and Binary type attributes must have lengths greater than zero. Set type attributes cannot be empty.
Read more >
Supplied AttributeValue is empty, must contain exactly one of ...
empty, must contain exactly one of the supported datatypes (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
Read more >
Expected - Amazon DynamoDB - AWS Documentation
EQ is supported for all datatypes, including lists and maps. AttributeValueList can contain only one AttributeValue element of type String, Number, Binary, ...
Read more >
DynamoDB putItem Validation Error - Bountysource
DynamoDB putItem Validation Error : Supplied AttributeValue is empty, must contain exactly one of the supported datatypes.
Read more >
Supplied AttributeValue is empty, must contain exactly one of ...
iOS : ValidationException : Supplied AttributeValue is empty, must contain exactly one of the supported datatypes [ Beautify Your Computer ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found