awslabs / awslabs/aws-mobile-appsync-sdk-android
AppSync S3 upload should fail in case uploaded file does not exists
- Dominant language
- Java
- Stars
- 106
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
AppSync tries to re-submit mutation with S3 upload which has a reference to non-existing File.
**To Reproduce**
1. Create mutation which will upload file to S3
2. Specify file which does not exist (or delete it before submitting mutation)
=> `AppSyncCustomNetworkInvoker.executeRequest()` will try to execute `s3ObjectManager.upload` and it will fail with `AmazonClientException(FileNotFoundException)` which is later will be catched and analyzed in this code-block, and mutation is not removed and AppSync retry it, so other mutations has no chance to be submitted (we have set a long timeout, so this block data-sync process)
```
if ( e.getCause() instanceof IOException ) {
//IO Exception occured indicating that there was a network issue.
//Set mutationInProgress status to false and return without removing the mutation from the queue.
queueHandler.setMutationInProgressStatusToFalse();
return;
}
```
**Expected behavior**
The mutation which throws `FileNotFoundException` during an attempt to push it to server should be considered as failed (File will not be created, it's a non-recoverable error)
**Environment:**
- AppSync SDK Version: 2.10.0
**Device Information:**
- Device: ANY
- Android Version: ANY
**Additional Context***
We've addressed this for now with such s3ObjectManager
```
class CustomS3ObjectManagerImplementation(s3Client: AmazonS3Client): S3ObjectManagerImplementation(s3Client) {
override fun upload(s3Object: S3InputObjectInterface) {
val file = File(s3Object.localUri())
if (!file.exists() || !file.isFile) {
throw FileNotFoundException("File ${s3Object.localUri()} does not exist or is not a file")
}
super.upload(s3Object)
}
}
```
Contributor guide
Research direction
Start at AppSyncCustomNetworkInvoker.executeRequest() and inspect how AmazonClientException caused by FileNotFoundException is handled during S3 upload. Done means a mutation referencing a missing file is treated as failed rather than retried indefinitely, allowing other queued mutations to proceed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, aws, java
- Domain
- backend-api-design, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100