Skip to content

can't ls the root of a bucket? #52

@alexhuth

Description

@alexhuth

I'm having trouble ls'ing the root of a bucket. might be a boto/botocore issue. the problem is that os.path.normpath turns '' into '.', and then botocore barfs.

for ref, boto is version 2.42.0, botocore is version 1.7.43. python 3.

In [37]: cci.ls('')
---------------------------------------------------------------------------
ClientError                               Traceback (most recent call last)
<ipython-input-37-cc8e9f569287> in <module>()
----> 1 cci.ls('')

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/utils.py in iremove_root(self, object_name, *args, **kwargs)
    264             object_name = object_name[1:]
    265 
--> 266         return input_function(self, object_name, *args, **kwargs)
    267     return iremove_root
    268 

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/interfaces.py in ls(self, pattern, page_size, limit, verbose)
    981         # get objects that match common prefix
    982         if not has_real_magic(pattern):
--> 983             object_names = self.lsdir(prefix, limit = limit)
    984         else:
    985             object_list = self.get_objects(filter = dict(Prefix = prefix),

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/interfaces.py in lsdir(self, path, limit)
    946             The children of the path.
    947         """
--> 948         return self.backend_interface.list_directory(path, limit)
    949 
    950     @clean_object_name

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/s3client.py in list_directory(self, path, limit)
    502                                                               Delimiter = SEPARATOR,
    503                                                               Prefix = path,
--> 504                                                               MaxKeys = limit)
    505         object_names = []
    506         if 'CommonPrefixes' in response:

/home/huth/anaconda3/lib/python3.5/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    310                     "%s() only accepts keyword arguments." % py_operation_name)
    311             # The "self" in this scope is referring to the BaseClient.
--> 312             return self._make_api_call(operation_name, kwargs)
    313 
    314         _api_call.__name__ = str(py_operation_name)

/home/huth/anaconda3/lib/python3.5/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    603             error_code = parsed_response.get("Error", {}).get("Code")
    604             error_class = self.exceptions.from_code(error_code)
--> 605             raise error_class(parsed_response, operation_name)
    606         else:
    607             return parsed_response

ClientError: An error occurred (XMinioInvalidResourceName) when calling the ListObjects operation: Resource name contains bad components such as ".." or ".".

also, related, running cci.ls with no arguments, which seems like it should ls the bucket root, just barfs because the decorator expects an argument:

In [40]: cci.ls()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-40-ff42535b08a1> in <module>()
----> 1 cci.ls()

TypeError: iremove_root() missing 1 required positional argument: 'object_name'

if that's intended behavior, fine.

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