soto-project / soto

Swift SDK for AWS that works on Linux, macOS and iOS
https://soto.codes
Apache License 2.0
878 stars 83 forks source link

Calls to headObject function sometimes leads to decoding errors #610

Closed robertgmelo closed 2 years ago

robertgmelo commented 2 years ago

Summary

As per previous discussion in Slack channel, it was requested the creation of a ticket to handle an intermittent issue when trying to access an object available on a bucket.

Here is the snippet:

let headObjectRequest = S3.HeadObjectRequest(bucket: bucket, key: key)
let headObject = s3.headObject(headObjectRequest)
...

The following error is triggered:

Error: dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "x-amz-storage-class", intValue: nil)], debugDescription: "Cannot initialize StorageClass from invalid String value NONE", underlyingError: nil))

How to Reproduce

Pre-conditions:

Steps to reproduce the behavior:

  1. Try to retrieve information about the object (s3.headObject)
  2. Observe the behavior

Expected behavior Retrieve an information about an object should occur without problems.

Setup (please complete the following information):

Additional context In fact, looking at AWS documentation, StorageClass object is properly defined, however it seems sometimes AWS returns the NONE value in the header x-amz-storage-class.

Here is the quote from AWS documentation:

x-amz-storage-class Provides storage class information of the object. Amazon S3 returns this header for all objects except for S3 Standard storage class objects. For more information, see Storage Classes. Valid Values: STANDARD | REDUCED_REDUNDANCY | STANDARD_IA | ONEZONE_IA | INTELLIGENT_TIERING | GLACIER | DEEP_ARCHIVE | OUTPOSTS | GLACIER_IR

robertgmelo commented 2 years ago

Suggestion: add NONE for StorageClass

adam-fowler commented 2 years ago

This should be fixed in v6.0.0