Skip to content

MinIO Python Client Fails to Handle Non-ASCII Characters in Access Key #1490

Closed
@weridolin

Description

@weridolin

Description:

I've encountered an issue while using the MinIO Python client where it fails to handle non-ASCII characters (e.g., Chinese characters) in the access key. However, the same setup works fine with the madmin-go client, which leads me to believe this might be specific to the Python implementation.

Steps to Reproduce:

  1. Create a new account with a non-ASCII character in its name (e.g., "中文测试").
  2. Attempt to list buckets using the MinIO Python client with this account's credentials.
  3. Observe the error when executing the script below.
from minio import Minio

client = Minio(
    "172.168.203.122:9000",
    access_key="中文测试",
    secret_key="123456789",
    secure=False
)

print(client.list_buckets())

Expected Behavior:
The client should successfully authenticate and return the list of buckets without any errors, similar to what happens with the madmin-go client.

Actual Behavior:
An error occurs during the execution:

Traceback (most recent call last):
  File "I:\dify_based_backEnd\api\controllers\console\minio_api.py", line 52, in get
    buckets_list = client.list_buckets()
                   ^^^^^^^^^^^^^^^^^^^^^
  File "D:\code\dify\api\venv\Lib\site-packages\minio\api.py", line 678, in list_buckets
    response = self._execute("GET")
               ^^^^^^^^^^^^^^^^^^^^
  File "D:\code\dify\api\venv\Lib\site-packages\minio\api.py", line 441, in _execute
    return self._url_open(
           ^^^^^^^^^^^^^^^
  File "D:\code\dify\api\venv\Lib\site-packages\minio\api.py", line 303, in _url_open
    response = self._http.urlopen(
               ^^^^^^^^^^^^^^^^^^^
  File "D:\code\dify\api\venv\Lib\site-packages\urllib3\poolmanager.py", line 443, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\code\dify\api\venv\Lib\site-packages\urllib3\connectionpool.py", line 787, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "D:\code\dify\api\venv\Lib\site-packages\urllib3\connectionpool.py", line 493, in _make_request
    conn.request(
  File "D:\code\dify\api\venv\Lib\site-packages\urllib3\connection.py", line 444, in request
    self.putheader(header, value)
  File "D:\code\dify\api\venv\Lib\site-packages\urllib3\connection.py", line 358, in putheader
    super().putheader(header, *values)
  File "D:\python311-64\Lib\http\client.py", line 1277, in putheader
    values[i] = one_value.encode('latin-1')

one_value.encode('latin-1')

Environment Information:

  • Python version: 3.11.9
  • MinIO Python client version: 7.2.15

For comparison, here is the working Go code snippet that does not produce any errors:

package main

import (
   "context"
   "fmt"
   "github.com/minio/madmin-go/v3"
)

func main() {
   ssl := false
   mdmClnt, err := madmin.New("172.168.203.122:9000", "中文名称", "12345678", ssl)
   if err != nil {
      fmt.Println(err)
      return
   }
   res, err := mdmClnt.GetUserInfo(context.Background(), "中文名称")
   if err != nil {
      fmt.Println(err)
      return
   }
   fmt.Println("user info", res)
}

Output from the Go code:

user info {<nil>  readwrite enabled [] 2025-03-31 02:16:09.961717943 +0000 UTC}

Please let me know if additional details or further clarification are needed.


This template follows the standard GitHub Issue format, providing clear steps to reproduce the issue, expected vs. actual behavior, and environment details. Adjust as needed for your specific situation.

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