findify / s3mock

Embedded S3 server for easy mocking
MIT License
387 stars 107 forks source link

Fix empty delimiter string not being considered as None #121

Closed tonicebrian closed 4 years ago

tonicebrian commented 6 years ago

In most of Python libraries like boto3, when listing contents of a bucket, an empty string as delimiter is considered as not provided (see for instance Apache Airflow). Also when using the boto3 library this 2 calls are semantically equivalent and return all keys under the bucket:

boto3.client('s3', region_name='eu-west-1').list_objects_v2(Bucket="mybucket")

and

boto3.client('s3', region_name='eu-west-1').list_objects_v2(Bucket="mybucket", Prefix='', Delimiter='')

But in S3Mock whenever you provide a string, it becomes Some("") as the delimiter and returns nothing. Since it doesn't make much sense to have an empty string as delimiter, I've created this PR to transform that into None in order to be able to interoperate with popular Python frameworks that hardcode the "" into the call.