Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValidationException : Supplied AttributeValue is empty, must contain exactly one of the supported datatypes

I am trying to insert a new record in a DynamoDB table named Users. I am getting data from the table. But whenever I try to insert a new record, I get the following error -

AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:86 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [{"__type":"com.amazon.coral.validate#ValidationException","message":"Supplied AttributeValue is empty, must contain exactly one of the supported datatypes"}]

My question is what causes this Exception and what would be the reason I am getting it? I am sure I do not have any empty variable (You can see in the attached info)

Information about the issue:

Here's the complete log of what I am trying to do -

AWSiOSSDKv2 [Verbose] AWSURLRequestSerialization.m line:111 | -[AWSJSONRequestSerializer serializeRequest:headers:parameters:] | Request body: [{"Key":{"phone_no":{"S":"Empty"}},"TableName":"Users","AttributeUpdates":{"signed_in_counts":{"Action":"DELETE"},"account_owner":{"Value":{"S":"Empty"},"Action":"PUT"},"email_id":{"Value":{"S":"Empty"},"Action":"PUT"},"catalog_ids":{"Value":{},"Action":"PUT"},"account_creation_date":{"Value":{"S":"Empty"},"Action":"PUT"},"title":{"Value":{"S":"Empty"},"Action":"PUT"},"date_of_birth":{"Value":{"S":"Empty"},"Action":"PUT"},"defaultOnlineStatus":{"Action":"DELETE"},"chat_enabled":{"Value":{"S":"YES"},"Action":"PUT"},"username":{"Value":{"S":"Empty"},"Action":"PUT"},"address_line1":{"Value":{"S":"Empty"},"Action":"PUT"},"last_name":{"Value":{"S":"Empty"},"Action":"PUT"},"last_date_of_sign_out":{"Value":{"S":"Empty"},"Action":"PUT"},"total_referrals":{"Action":"DELETE"},"last_date_signed_in":{"Value":{"S":"Empty"},"Action":"PUT"},"first_name":{"Value":{"S":"Empty"},"Action":"PUT"},"activated":{"Value":{"S":"YES"},"Action":"PUT"}}}]
2015-04-20 15:44:53.434 Barnc[534:65423] AWSiOSSDKv2 [Debug] AWSSignature.m line:305 | -[AWSSignatureV4Signer signRequestV4:] | AWS4 Canonical Request: [POST
/

accept-encoding:
content-type:application/x-amz-json-1.0
host:dynamodb.us-east-1.amazonaws.com
user-agent:aws-sdk-iOS/2.1.0 iPhone-OS/8.3 en_IN
x-amz-date:20150420T101453Z
x-amz-security-token:XXX
x-amz-target:DynamoDB_20120810.UpdateItem

accept-encoding;content-type;host;user-agent;x-amz-date;x-amz-security-token;x-amz-target
93a6af5de49c12a33621c58cbc3ea7c9bbd8cd59660531bef10ea81c36acb06f]
2015-04-20 15:44:53.436 Barnc[534:65423] AWSiOSSDKv2 [Debug] AWSSignature.m line:306 | -[AWSSignatureV4Signer signRequestV4:] | payload {"Key":{"phone_no":{"S":"Empty"}},"TableName":"Users","AttributeUpdates":{"signed_in_counts":{"Action":"DELETE"},"account_owner":{"Value":{"S":"Empty"},"Action":"PUT"},"email_id":{"Value":{"S":"Empty"},"Action":"PUT"},"catalog_ids":{"Value":{},"Action":"PUT"},"account_creation_date":{"Value":{"S":"Empty"},"Action":"PUT"},"title":{"Value":{"S":"Empty"},"Action":"PUT"},"date_of_birth":{"Value":{"S":"Empty"},"Action":"PUT"},"defaultOnlineStatus":{"Action":"DELETE"},"chat_enabled":{"Value":{"S":"YES"},"Action":"PUT"},"username":{"Value":{"S":"Empty"},"Action":"PUT"},"address_line1":{"Value":{"S":"Empty"},"Action":"PUT"},"last_name":{"Value":{"S":"Empty"},"Action":"PUT"},"last_date_of_sign_out":{"Value":{"S":"Empty"},"Action":"PUT"},"total_referrals":{"Action":"DELETE"},"last_date_signed_in":{"Value":{"S":"Empty"},"Action":"PUT"},"first_name":{"Value":{"S":"Empty"},"Action":"PUT"},"activated":{"Value":{"S":"YES"},"Action":"PUT"}}}
2015-04-20 15:44:53.439 Barnc[534:65423] AWSiOSSDKv2 [Debug] AWSSignature.m line:322 | -[AWSSignatureV4Signer signRequestV4:] | AWS4 String to Sign: [AWS4-HMAC-SHA256
20150420T101453Z
20150420/us-east-1/dynamodb/aws4_request
3d4769e2a1f73aee21f7ef26ae389183852118fbf078261e1a293262f0ac97d3]
2015-04-20 15:44:54.748 Barnc[534:66289] AWSiOSSDKv2 [Debug] AWSURLResponseSerialization.m line:81 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response header: [{
    "Content-Length" = 156;
    "Content-Type" = "application/x-amz-json-1.0";
    Date = "Mon, 20 Apr 2015 10:14:53 GMT";
    "x-amz-crc32" = 1541720790;
    "x-amzn-RequestId" = XXX;
}]
2015-04-20 15:44:54.748 Barnc[534:66289] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:86 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: 

[{"__type":"com.amazon.coral.validate#ValidationException","message":"Supplied AttributeValue is empty, must contain exactly one of the supported datatypes"}]
The request failed. Error: [Error Domain=com.amazonaws.AWSDynamoDBErrorDomain Code=0 "The operation couldn’t be completed. (com.amazonaws.AWSDynamoDBErrorDomain error 0.)" UserInfo=0x1760c310 {message=Supplied AttributeValue is empty, must contain exactly one of the supported datatypes, __type=com.amazon.coral.validate#ValidationException}]

I have tried to put dummy data in the data model to not have any empty variable. But it doesn't seem to work.

Here's how I am inserting the record -

-(void)saveUser:(BarncUser*)user{
    [user autoValidate];
    [[dynamoDBObjectMapper save:user.amazonUser]
     continueWithBlock:^id(BFTask *task) {
         if (task.error) {
             NSLog(@"The request failed. Error: [%@]", task.error);
         }
         if (task.exception) {
             NSLog(@"The request failed. Exception: [%@]", task.exception);
         }
         if (task.result) {
             //Do something with the result.
         }
         return nil;
     }];
}

My Data Model looks like this -

@interface AmazonUser : AWSDynamoDBObjectModel <AWSDynamoDBModeling>

@property (nonatomic, strong) NSString *phone_no;
@property (nonatomic, strong) NSString *activated;
@property (nonatomic, strong) NSMutableArray *catalog_ids;
@property (nonatomic, strong) NSNumber *defaultOnlineStatus;
@property (nonatomic, strong) NSNumber *signed_in_counts;
@property (nonatomic, strong) NSNumber *total_referrals;
@property (nonatomic, strong) NSString *account_creation_date;
@property (nonatomic, strong) NSString *email_id;
@property (nonatomic, strong) NSString *account_owner;
@property (nonatomic, strong) NSString *username;
@property (nonatomic, strong) NSString *first_name;
@property (nonatomic, strong) NSString *chat_enabled;
@property (nonatomic, strong) NSString *last_name;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *last_date_of_sign_out;
@property (nonatomic, strong) NSString *date_of_birth;
@property (nonatomic, strong) NSString *last_date_signed_in;
@property (nonatomic, strong) NSString *address_line1;

- (void)createDummy;

@end

@implementation AmazonUser

+ (NSString *)dynamoDBTableName {
    return @"Users";
}

+ (NSString *)hashKeyAttribute {
    return @"phone_no";
}

- (void)createDummy{

    self.phone_no = @"Empty";
    self.activated = @"YES";
    self.catalog_ids = [[NSMutableArray alloc]init];
    self.defaultOnlineStatus = 0;
    self.signed_in_counts = 0;
    self.total_referrals = 0;
    self.account_creation_date = @"Empty";
    self.email_id = @"Empty";
    self.account_owner = @"Empty";
    self.username = @"Empty";
    self.first_name = @"Empty";
    self.chat_enabled = @"YES";
    self.last_name = @"Empty";
    self.title = @"Empty";
    self.last_date_of_sign_out = @"Empty";
    self.date_of_birth = @"Empty";
    self.last_date_signed_in = @"Empty";
    self.address_line1 = @"Empty";
}
like image 649
noob Avatar asked Apr 20 '15 11:04

noob


1 Answers

The NSMutableArray catalog_ids is still empty judging from the log:

catalog_ids":{"Value":{},"Action":"PUT"}

In the documentation on the DynamoDB Data Model it is mentioned that DynamoDB does not support empty sets for Multi-Valued Data Types. Try initialising the array with non-zero values.

like image 152
Ruud Kalis Avatar answered Oct 04 '22 02:10

Ruud Kalis