minio / minio-py

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

Inconsistent behaviour when setting and retrieving metadata: returned metadata has x-amz prefix #1317

Closed erny closed 1 year ago

erny commented 1 year ago

Client version: 7.1.13 Server version: 2023-03-24T21:41:23Z

When putting objects, metadata is normalized with "X-Amz" prefix:

put_object -> genheaders -> normalize_headers -> _metadata_to_headers: https://github.com/minio/minio-py/blob/6562b765954af6beff2bc2c691b7d87060f0e011/minio/helpers.py#L297-L302

But when retrieving an object using stat_object (-> _execute), an Object is returned: https://github.com/minio/minio-py/blob/6562b765954af6beff2bc2c691b7d87060f0e011/minio/api.py#L1908-L1917 and any hearders are attached directly to ._metadata (without transforms) https://github.com/minio/minio-py/blob/6562b765954af6beff2bc2c691b7d87060f0e011/minio/datatypes.py#L119

But it is not transformed when getting the metadata https://github.com/minio/minio-py/blob/6562b765954af6beff2bc2c691b7d87060f0e011/minio/datatypes.py#L158-L161

balamurugana commented 1 year ago

This is expected behavior to avoid conflicting return values. The user should aware that x-amz-meta should be prefixed for all user metadata.