Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientError: An error occurred (403) when calling the HeadBucket operation: Forbidden #87

Open
jenholmberg opened this issue Feb 2, 2023 · 1 comment · Fixed by #89

Comments

@jenholmberg
Copy link
Contributor

jenholmberg commented Feb 2, 2023

Encountered ClientError: An error occurred (403) when calling the HeadBucket operation: Forbidden when trying cc.get_interface(). The issue was solved by changing the versions of my botocore and boto3.
I downgraded botocore from 1.29.63 to 1.19 and boto3 from 1.26.63 to 1.15.

jenholmberg added a commit to jenholmberg/cottoncandy that referenced this issue Mar 20, 2023
jenholmberg added a commit to jenholmberg/cottoncandy that referenced this issue Mar 21, 2023
micwinter added a commit that referenced this issue Jul 25, 2023
update boto requirements to address issue #87
@mvdoc mvdoc reopened this Feb 28, 2025
@mvdoc
Copy link
Contributor

mvdoc commented Feb 28, 2025

Here's the traceback with the latest version of botocore

---------------------------------------------------------------------------                                                                                                                                                                                                                                       [33/45965]
ClientError                               Traceback (most recent call last)
Cell In[6], line 1
----> 1 cci = cc.get_interface("glab-share")

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/__init__.py:74, in get_interface(bucket_name, ACCESS_KEY, SECRET_KEY, endpoint_url, force_bucket_creation, verbose, backend, **kwargs)
     71     from botocore.client import Config
     72     kwargs['config'] = Config(signature_version=DEFAULT_SIGNATURE_VERSION)
---> 74 interface = DefaultInterface(bucket_name,
     75                              ACCESS_KEY,
     76                              SECRET_KEY,
     77                              endpoint_url,
     78                              force_bucket_creation,
     79                              verbose=verbose,
     80                              backend = backend,
     81                              **kwargs)
     82 return interface

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/interfaces.py:1414, in DefaultInterface.__init__(self, *args, **kwargs)
   1396 def __init__(self, *args, **kwargs):
   1397     """
   1398     Parameters
   1399     ----------
   (...)
   1412     cci  : cottoncandy.InterfaceObject
   1413     """
-> 1414     super(DefaultInterface, self).__init__(*args, **kwargs)

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/interfaces.py:1025, in FileSystemInterface.__init__(self, *args, **kwargs)
   1008 def __init__(self, *args, **kwargs):
   1009     """
   1010     Parameters
   1011     ----------
   (...)
   1023         Cottoncandy interface object
   1024     """
-> 1025     super(FileSystemInterface, self).__init__(*args, **kwargs)

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/interfaces.py:520, in ArrayInterface.__init__(self, *args, **kwargs)
    503 def __init__(self, *args, **kwargs):
    504     """
    505     Parameters
    506     ----------
   (...)
    518         Cottoncandy interface object
    519     """
--> 520     super(ArrayInterface, self).__init__(*args, **kwargs)

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/interfaces.py:111, in BasicInterface.__init__(self, bucket_name, ACCESS_KEY, SECRET_KEY, url, force_bucket_creation, verbose, backend, **kwargs)
    108 bucket_name = None if bucket_name == '' else bucket_name
    110 if backend == 's3':
--> 111     self.backend_interface = S3Client(bucket_name, ACCESS_KEY, SECRET_KEY, url,
    112                                       force_bucket_creation,
    113                                       **kwargs)
    114 elif backend == 'gdrive':
    115     from .gdriveclient import GDriveClient

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/s3client.py:73, in S3Client.__init__(self, bucket, access_key, secret_key, s3url, force_bucket_creation, **kwargs)
     69 self.bucket_name = None
     71 if bucket:
     72     # bucket given
---> 73     if self.check_bucket_exists(bucket):
     74         self.set_current_bucket(bucket)
     75     elif force_bucket_creation:

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/s3client.py:147, in S3Client.check_bucket_exists(self, bucket_name)
    145         exists = False
    146     else:
--> 147         raise e
    148 else:
    149     exists = True

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/cottoncandy/s3client.py:142, in S3Client.check_bucket_exists(self, bucket_name)
    131 """Check whether the bucket exists
    132
    133 Parameters
   (...)
    139
    140 """
    141 try:
--> 142     self.connection.meta.client.head_bucket(Bucket = bucket_name)
    143 except botocore.exceptions.ClientError as e:
    144     if e.response['Error']['Code'] == "404":

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/botocore/client.py:569, in ClientCreator._create_api_method.<locals>._api_call(self, *args, **kwargs)
    565     raise TypeError(
    566         f"{py_operation_name}() only accepts keyword arguments."
    567     )
    568 # The "self" in this scope is referring to the BaseClient.
--> 569 return self._make_api_call(operation_name, kwargs)

File ~/miniconda3/envs/cottoncandy-dev/lib/python3.13/site-packages/botocore/client.py:1023, in BaseClient._make_api_call(self, operation_name, api_params)
   1019     error_code = error_info.get("QueryErrorCode") or error_info.get(
   1020         "Code"
   1021     )
   1022     error_class = self.exceptions.from_code(error_code)
-> 1023     raise error_class(parsed_response, operation_name)
   1024 else:
   1025     return parsed_response

ClientError: An error occurred (403) when calling the HeadBucket operation: Forbidden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants