简体   繁体   English

AWS DynamoDB iOS SDK静默失败,但始终返回成功状态

[英]AWS DynamoDB iOS SDK silently failing but always returning success status

I've created an iOS application following AWS Mobile SDK examples using AWSiOSSDKv2. 我已使用AWSiOSSDKv2按照AWS Mobile SDK示例创建了一个iOS应用程序。

I've successfully been able to connect with an unauthorized Cognito account to DynamoDB and write to the table. 我已经能够成功地使用未经授权的Cognito帐户连接到DynamoDB并写入表中。 I log into AWS, check the table and see my records are there. 我登录到AWS,检查表并查看我的记录在那里。

AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];
[[dynamoDBObjectMapper save:tableRow] continueWithSuccessBlock:^id(BFTask *task) {
    if (!task.error) {
        NSLog(@"Successfully inserted the data into the table.");
    } else {
        NSLog(@"Failed to insert the data into the table.");
    }
    return nil;
}];

However, now I want to test what will happen in a failure. 但是,现在我想测试失败时会发生什么。 I deliberately try to cause an error by changing the dynamoDBTableName to something that does not exist. 我故意尝试通过将dynamoDBTableName更改为不存在的内容来导致错误。 Unfortunately, my code always returns success even tho it was not. 不幸的是,即使没有,我的代码也总是返回成功。

I found in another thread someone recommending putting logging to verbose which I did. 我在另一个线程中发现有人建议将日志记录设为详细信息,就像我所做的那样。

[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;

And in the console, I do see that AWSLogger displays an error: 而且在控制台中,我确实看到AWSLogger显示错误:

[{"__type":"com.amazon.coral.service#AccessDeniedException","Message":"User: arn:aws:sts::xxxxxx:assumed-role/Cognito_xxxxxxxxUnauth_DefaultRole/iOS-Provider is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-east-1:xxxxxxxxxxxxx:table/xxxxxxxx"}] [{“ __type”:“ com.amazon.coral.service#AccessDeniedException”,“消息”:“用户:arn:aws:sts :: xxxxxx:assumed-role / Cognito_xxxxxxxxUnauth_DefaultRole / iOS-Provider未经授权执行:dynamodb :在资源上放置项:arn:aws:dynamodb:us-east-1:xxxxxxxxxxxxx:table / xxxxxxxx“}]

However, In my code above, it always writes "Successfully inserted the data into the table.". 但是,在上面的代码中,它始终写为“成功将数据插入表中”。

I've even tried modifying AWS Mobile Examples and can reproduce the same bug. 我什至尝试修改AWS Mobile示例,并且可以重现相同的错误。 I've also tried installing the POD and manually adding the AWSiOSSDKv2 framework to my project, neither fix the issue. 我还尝试安装POD并手动将AWSiOSSDKv2框架添加到我的项目中,但均未解决问题。

Has anyone run into this issue and does anyone know how to resolve? 有没有人遇到这个问题,有人知道如何解决吗? I'm trying to create an unauthorized user who only has write access to the dynamodb table. 我正在尝试创建仅对dynamodb表具有写访问权的未授权用户。

Thanks 谢谢

This is a known issue of the SDK, and the fix is on its way. 这是SDK的已知问题 ,修补程序正在进行中。

In the meanwhile, if you are using CocoaPods, adding the following lines to AWSDynamoDBObjectMapper.m L154 should fix it: 同时,如果您使用的是CocoaPods,则将以下行添加到AWSDynamoDBObjectMapper.m L154应该可以解决此问题:

if (task.error) {
    return task;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM