oracle / oci-go-sdk

Go SDK for Oracle Cloud Infrastructure
https://cloud.oracle.com/cloud-infrastructure
Other
178 stars 83 forks source link

Object Storage HEAD requests to buckets fail #517

Open mikattack opened 4 months ago

mikattack commented 4 months ago

SDK Version: 65

Given an authenticated session, some code like the following:

osc, err := objectstorage.NewObjectStorageClientWithConfigurationProvider(provider)
if err != nil {
    return objectstorage.HeadBucketResponse{}, err
}

req := objectstorage.HeadBucketRequest{
    BucketName:    common.String(cfg.ObjectStorage.Bucket),
    NamespaceName: common.String(cfg.ObjectStorage.Namespace),
}

rsp, err := osc.HeadBucket(context.Background(), req)
if rsp.RawResponse.StatusCode == http.StatusUnauthorized {
    return rsp, AuthenticationFailure
}
return rsp, err

...fails with a an error like the following:

Error returned by ObjectStorage Service. Http Status Code: 401. Error Code: BadErrorResponse.
Opc request id: iad-1:zSYuRlNaTRBe4ENuRqsNzg1c3-b7p-ZBQYMOxm0aa-pRICqAIoQ5Ui1hLLiOmjdW. 
Message: Failed to parse json from response body due to: unexpected end of JSON input. 
With response body .

The response body should not be parsed for HEAD requests, as there should never be a response body with HEAD responses.

I believe this is an error in the SDK.

richachugh11 commented 2 months ago

hi @mikattack , I wanted to follow up to see if you are still facing this issue? If so, can you try accessing other buckets or performing different operations to determine if the issue is specific to this bucket?