minio / minio-py

MinIO Client SDK for Python
https://docs.min.io/docs/python-client-quickstart-guide.html
Apache License 2.0
822 stars 318 forks source link

Metadata values starting with space leading to signature mismatch on PUT #1434

Closed sidharthrajaram closed 1 month ago

sidharthrajaram commented 1 month ago

When the following is done:

minio_client.fput_object(
    MY_BUCKET,
    f"some/path/file.ext",
    my_file_path,
    metadata={"SomeField": "     some value"}
)

Signature mismatch occurs:

minio.error.S3Error: S3 operation failed; code: SignatureDoesNotMatch, message: The request signature we calculated does not match the signature you provided. Check your key and signing method.

When I remove the spaces before some value, put object happens fine.

Looks like there is replacement/removal of spaces happening here: https://github.com/minio/minio-py/blob/57c5e377d0a14cd3b866c8013f7f4e45223f7165/minio/signer.py#L77 prior to signing which is leading to the signature mismatch.

sidharthrajaram commented 1 month ago

Tested same thing on Go SDK with no issue.