Skip to content

File gets cached as folder when s3-compatible storage does not receive correct region #329

Open
@georgeboot

Description

@georgeboot

Given the following code:

from cloudpathlib import CloudPath, S3Client

%env AWS_ACCESS_KEY_ID=SCWxxxxxxxxxxxx
%env AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxx

s3_client = S3Client(endpoint_url='https://s3.fr-par.scw.cloud')
bucket = CloudPath('s3://my-scw-bucket-name', client=s3_client)
file = bucket.joinpath('folder/file.txt')
file.read_text(encoding="utf-8") # error!

This will result in the following error:

IsADirectoryError: [Errno 21] Is a directory: '/tmp/tmpcwvt0_jn/my-scw-bucket-name/folder/file.txt'

However, when we also add the region in the mix (by adding %env AWS_DEFAULT_REGION=fr-par to the header), it works.

The region should probably always be set for s3-compatible storage, but this error is very misleading. Any ways to make this easier to debug?

To be fair, when running the above code with Cloudflare R2, it spits out an 'unsupported region' error on the first operation. Somehow, Scaleway's S3 storage seems to accept some requests with an incorrect region.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions