Closed bjornuppeke closed 2 months ago
Object name must be str, not byte-like object.
But the error says the opposite, right?
@bjornuppeke Refer https://github.com/minio/minio-py/blob/master/minio/helpers.py#L270, https://github.com/minio/minio-py/blob/master/minio/api.py#L2218 and https://github.com/minio/minio-py/blob/master/minio/api.py#L2288. This is not minio-py
issue.
Since 7.2.8 this exception is thrown in a Django app that depends on django-minio-backend which in turn depends on the Minio python SDK:
File "/venv/lib/python3.11/site-packages/asgiref/sync.py", line 518, in thread_handler raise exc_info[1] File "/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 253, in _get_response_async response = await wrapped_callback( ^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/asgiref/sync.py", line 468, in call ret = await asyncio.shield(exec_coro) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/asgiref/current_thread_executor.py", line 40, in run result = self.fn(*self.args, self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/asgiref/sync.py", line 522, in thread_handler return func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view return view_func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view return self.dispatch(request, *args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/venv/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/venv/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/generics.py", line 190, in post return self.create(request, args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/code/backend/helpdesk/views.py", line 24, in create headers = self.get_success_headers(serializer.data) ^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/serializers.py", line 555, in data ret = super().data ^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/serializers.py", line 253, in data self._data = self.to_representation(self.instance) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/serializers.py", line 522, in to_representation ret[field.field_name] = field.to_representation(attribute) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/venv/lib/python3.11/site-packages/rest_framework/serializers.py", line 686, in to_representation return [ ^ File "/venv/lib/python3.11/site-packages/rest_framework/serializers.py", line 687, in
self.child.to_representation(item) for item in iterable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/rest_framework/serializers.py", line 522, in to_representation
ret[field.field_name] = field.to_representation(attribute)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/rest_framework/fields.py", line 1517, in to_representation
url = value.url
^^^^^^^^^
File "/venv/lib/python3.11/site-packages/django/db/models/fields/files.py", line 67, in url
return self.storage.url(self.name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/django_minio_backend/models.py", line 260, in url
u: str = client.presigned_get_object(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/minio/api.py", line 2325, in presigned_get_object
return self.get_presigned_url(
^^^^^^^^^^^^^^^^^^^^^^^
File "/venv/lib/python3.11/site-packages/minio/api.py", line 2255, in get_presigned_url
check_object_name(object_name)
File "/venv/lib/python3.11/site-packages/minio/helpers.py", line 273, in check_object_name
tokens = object_name.split("/")
^^^^^^^^^^^^^^^^^^^^^^
TypeError: a bytes-like object is required, not \'str\''}