Skip to content

Using minio go sdk to request AWS S3 sometimes returns 400 Bad Request #2045

@huanghaoyuanhhy

Description

@huanghaoyuanhhy

When using the MinIO Go SDK to call AWS S3 service, it occasionally returns a 400 Bad Request response.

Upon investigation, we found that if the region is not specified, the SDK calls GetBucketLocation and relies on the AuthorizationHeaderMalformed response to extract the correct region. However, AWS does not always include the region in the AuthorizationHeaderMalformed response.

This causes external applications using the MinIO Go SDK to send requests to AWS S3 with the default us-east-1 region in the auth header. AWS rejects such requests, returning a 400 Bad Request error.

The AWS documentation states:

We recommend that you use HeadBucket to return the Region that a bucket resides in. For backward compatibility, Amazon S3 continues to support GetBucketLocation.

It seems that using HeadBucket instead of GetBucketLocation to fetch the bucket's region would be a more reliable approach.

Could the SDK be updated to prefer HeadBucket for determining the bucket's region to avoid these issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions