oracle/oci-java-sdk

Error on HeadBucket: Unexpected Content-Type: null instead of application/json.

alexmaycon opened this issue · 4 comments

Hello!

I'm getting the error Unexpected Content-Type: null instead of application/json. when making a request on the HeadBucket endpoint.

HeadBucketRequest headBucketRequest = HeadBucketRequest.builder()
                .retryConfiguration(retryConfiguration())
                .namespaceName(namespace)
                .bucketName(bucketName)
                .build();

        return objectStorage.headBucket(headBucketRequest);
2022-10-11 21:54:44.231 ERROR 17304 --- [h_upload_files2] o.s.batch.core.step.AbstractStep         : Encountered an error executing step step_temp_40c06d9c-05cf-4111-b248-765153d34510 in job DEFAULT_CRON_JOB

com.oracle.bmc.model.BmcException: Error returned by HeadBucket operation in ObjectStorage service.(404, Unknown, false) Unexpected Content-Type: null instead of application/json. Response body:  (opc-request-id: gru-1:crCj7gSQ_Si9pKRT3o04zCQK8BA5uxNT7KGUBi3asllY1J_Sds79rPZWSpSfuL-X)
Timestamp: 2022-10-12T00:54:44.223Z
Client version: Oracle-JavaSDK/2.46.0
Request Endpoint: https://objectstorage.sa-saopaulo-1.oraclecloud.com/n/gr4twzrcmz46/b/teste2
Troubleshooting Tips: See https://docs.oracle.com/en-us/iaas/Content/API/References/apierrors.htm#apierrors_404__404_unknown for more information about resolving this error
Also see https://docs.oracle.com/iaas/api/#/en/objectstorage/20160918/Bucket/HeadBucket for details on this operation's requirements.
To get more info on the failing request, you can enable debug level logs as mentioned in `Using SLF4J for Logging section` in https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/javasdkconfig.htm.
If you are unable to resolve this ObjectStorage issue, please contact Oracle support and provide them this full error message.

The user policy are:

Allow group buckets to manage buckets in tenancy

Can anyone help?

Thanks!!

@alexmaycon if you do a GetBucket call on the same bucket/namespace, does the call succeed, or do you get an error? If an error, what is the error?

@alexmaycon if you do a GetBucket call on the same bucket/namespace, does the call succeed, or do you get an error? If an error, what is the error?

Hi @jodoglevy, it returns an error (404, BucketNotFound) because the bucket I'm trying to get doesn't actually exist. I'm using HeadBucket to validate exactly that, when it doesn't exist (HeadBucket=404) I'll be creating the bucket.

ok. but the HeadBucket did return a 404, right? I agree the error message is confusing, but couldn't your code still use that 404 returned from HeadBucket for what you're looking to accomplish?

Got it, I'll tweak the code. Thanks @jodoglevy.