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 7 months 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