Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWSS3 headObject returns Error Domain=com.amazonaws.AWSS3ErrorDomain Code=0 instead of AWSS3ErrorNoSuchKey #5496

Open
bvirlet opened this issue Jan 20, 2025 · 1 comment
Labels
bug Something isn't working pending-triage Issue is pending triage s3 Issues related to S3

Comments

@bvirlet
Copy link

bvirlet commented Jan 20, 2025

Describe the bug

When performing a AWSS3.headObject on a missing key, the SDK returns a Error Domain=com.amazonaws.AWSS3ErrorDomain Code=0 instead of a AWSS3ErrorNoSuchKey code.

To Reproduce
Steps to reproduce the behavior, make a headObject request on a missing key.

Observed Behavior

No result is present as expected, but the error is Error Domain=com.amazonaws.AWSS3ErrorDomain Code=0.

s3.headObject(request).continueWith(block: { task in
    if let result = task.result {
        print(result)
    }
    print(error)
})

Expected Behavior

The error should be AWSS3ErrorNoSuchKey. This is what is documented:

An instance of AWSTask. On successful execution, task.result will contain an instance of AWSS3HeadObjectOutput. On failed execution, task.error may contain an NSError with AWSS3ErrorDomain domain and the following error code: AWSS3ErrorNoSuchKey.

Areas of the SDK you are using (AWSMobileClient, Cognito, Pinpoint, IoT, etc)?
AWSS3

Environment(please complete the following information):

  • SDK Version: 2.40.0 (2.23.0 as well)
  • Dependency Manager: SPM
  • Swift Version : 5.0
  • Xcode Version: 16.1

Additional context

I think the problem is that the HEAD request doesn't return a body, but the SDK parses errors from the body. In the case of an HEAD request, the NoSuchKey error should just be inferred from the HTTP 404 status as head object requests from S3 don't return a body.

@github-actions github-actions bot added pending-triage Issue is pending triage pending-maintainer-response Issue is pending response from an Amplify team member labels Jan 20, 2025
@thisisabhash thisisabhash added bug Something isn't working s3 Issues related to S3 labels Jan 21, 2025
@thisisabhash
Copy link
Member

Thank you for posting this issue. Our team will take a look and post updates here.

@github-actions github-actions bot removed the pending-maintainer-response Issue is pending response from an Amplify team member label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-triage Issue is pending triage s3 Issues related to S3
Projects
None yet
Development

No branches or pull requests

2 participants