oci-go-sdk icon indicating copy to clipboard operation
oci-go-sdk copied to clipboard

Object Storage HEAD requests to buckets fail

Open mikattack opened this issue 1 year ago • 1 comments

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.

mikattack avatar Jul 12 '24 17:07 mikattack

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?

richachugh11 avatar Sep 25 '24 23:09 richachugh11