drivendataorg / drivendataorg/cloudpathlib
Joining a cloudpath and string representing an absolute path removes the bucket name
- Dominant language
- Python
- Stars
- 628
- Forks
- 88
- Avg merge
- 17h 28m
- Merged PRs (30d)
- 2
Description
```
from cloudpathlib import CloudPath
# absolute local path
local_path = '/tmp/some-file.txt'
# the local path is used directly to construct the cloud path
cloud_path = CloudPath('s3://some-bucket') / local_path
# the upload will fail
cloud_path.upload_from(local_path)
```
There are two errors in the output:
- `An error occurred (403) when calling the HeadObject operation: Forbidden`
- `An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied`
but neither of them explains the actual cause.
```
Traceback (most recent call last):
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/cloudpathlib/s3/s3client.py", line 186, in _s3_file_query
self.client.head_object(
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/botocore/client.py", line 530, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/botocore/client.py", line 960, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (403) when calling the HeadObject operation: Forbidden
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/cloudpathlib/cloudpath.py", line 842, in upload_from
if self.exists() and self.is_dir():
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/cloudpathlib/cloudpath.py", line 389, in exists
return self.client._exists(self)
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/cloudpathlib/s3/s3client.py", line 179, in _exists
return self._s3_file_query(cloud_path) is not None
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/cloudpathlib/s3/s3client.py", line 197, in _s3_file_query
return next(
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/cloudpathlib/s3/s3client.py", line 198, in
(
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/boto3/resources/collection.py", line 81, in __iter__
for page in self.pages():
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/boto3/resources/collection.py", line 171, in pages
for page in pages:
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/botocore/paginate.py", line 269, in __iter__
response = self._make_request(current_kwargs)
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/botocore/paginate.py", line 357, in _make_request
return self._method(**current_kwargs)
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/botocore/client.py", line 530, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/users/foo/.pyenv/versions/bar-env/lib/python3.10/site-packages/botocore/client.py", line 960, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListObjects operation: Access Denied
```
Contributor guide
Assessment
This issue has not been assessed yet.