Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Can't use errors.Is() and errors.As() with s3's ListParts() #63

Closed
3 tasks done
F21 opened this issue Apr 22, 2021 · 4 comments
Closed
3 tasks done

Can't use errors.Is() and errors.As() with s3's ListParts() #63

F21 opened this issue Apr 22, 2021 · 4 comments
Assignees
Labels
bug Something isn't working s3

Comments

@F21
Copy link

F21 commented Apr 22, 2021

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
When using ListParts to list the parts of a multipart upload, if the upload does not exist, a NoSuchKey error is returned. This is evident when printing the error: https response error StatusCode: 404, RequestID: tx00000000000000000095a-00608116e2-1014-default, HostID: 1014-default-default, api error NoSuchKey: UnknownError.

The problem is that the types.NoSuchKey error is not in the error chain, so it is impossible to use error.Is() or errors.As() to unwrapped the error chain into a types.NoSuchKey.

Version of AWS SDK for Go?
Example: v1.3.3

Version of Go (go version)?
1.16.2

To Reproduce (observed behavior)

_, err := c.s3Client.ListParts(ctx, &s3.ListPartsInput{
  Bucket:     aws.String("mybucket"),
  Key:          aws.String("invalidkey"),
  UploadId: aws.String("uploadID"),
  MaxParts: 10000,
})

if err != nil {
  if errors.Is(err, &types.NoSuchKey{}){
    fmt.Println("Is NoSuchKey error")
  }
}

Expected behavior
Is NoSuchKey error should be printed.

@F21 F21 changed the title Can use errors.Is() and errors.As() with s3's ListParts() Can't use errors.Is() and errors.As() with s3's ListParts() Apr 22, 2021
@skotambkar
Copy link

Thanks for letting us know. S3 does not model NoSuchKey as an error for that operation and thus the error isn't deserialized into that type. Transferring this issue to aws-sdk repo as this affects all sdks.

@skotambkar skotambkar transferred this issue from aws/aws-sdk-go-v2 May 7, 2021
@NGL321 NGL321 added bug Something isn't working service-api This issue pertains to the AWS API labels May 24, 2021
@KaibaLopez KaibaLopez added the s3 label Jul 20, 2021
@stobrien89 stobrien89 removed the service-api This issue pertains to the AWS API label Jul 26, 2021
@vudh1 vudh1 assigned vudh1 and unassigned KaibaLopez Mar 14, 2022
@vudh1
Copy link

vudh1 commented Sep 2, 2022

P71069218

@vudh1 vudh1 removed the needs-ticket label Sep 2, 2022
@vudh1 vudh1 assigned RanVaknin and unassigned vudh1 Sep 9, 2022
@RanVaknin
Copy link

Hi,

S3 now has proper error modeling for non existent upload, the API now returns a NoSuchUpload which you can reliably error handle on.

<?xml version="1.0" encoding="UTF-8"?>
<Error>
  <Code>NoSuchUpload</Code>
  <Message>The specified upload does not exist. The upload ID may be invalid, or the upload may have been aborted or completed.</Message>
  <UploadId>uploadID</UploadId>
  <RequestId>REDACTED</RequestId>
  <HostId>REDACTED</HostId>
</Error>

Thanks again,
Ran~

Copy link

This issue is now closed.

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working s3
Projects
None yet
Development

No branches or pull requests

7 participants