diff --git a/physical/s3.go b/physical/s3.go index eb7983d55..1b476eea2 100644 --- a/physical/s3.go +++ b/physical/s3.go @@ -120,7 +120,6 @@ func (s *S3Backend) Get(key string) (*Entry, error) { Bucket: aws.String(s.bucket), Key: aws.String(key), }) - if awsErr, ok := err.(awserr.RequestFailure); ok { // Return nil on 404s, error on anything else if awsErr.StatusCode() == 404 { @@ -129,6 +128,12 @@ func (s *S3Backend) Get(key string) (*Entry, error) { return nil, err } } + if err != nil { + return nil, err + } + if resp == nil { + return nil, fmt.Errorf("got nil response from S3 but no error") + } data := make([]byte, *resp.ContentLength) _, err = io.ReadFull(resp.Body, data) @@ -172,6 +177,9 @@ func (s *S3Backend) List(prefix string) ([]string, error) { if err != nil { return nil, err } + if resp == nil { + return nil, fmt.Errorf("nil response from S3 but no error") + } keys := []string{} for _, key := range resp.Contents {