IBM / ibm-cos-sdk-python

ibm-cos-sdk-python
Apache License 2.0
44 stars 26 forks source link

ValueError: Invalid endpoint: s3.us-east.cloud-object-storage.appdomain.cloud #22

Closed vmorris closed 5 years ago

vmorris commented 5 years ago

version: ibm_cos_sdk-2.4.3

I'm following the documentation here: https://console.bluemix.net/docs/services/cloud-object-storage/libraries/python.html#init-config

Attempting to create an ibm_boto3.client results in the following trace:

Traceback (most recent call last):
  File "./upload.py", line 20, in <module>
    client = boto3.client('s3', endpoint_url=credentials.get('service_endpoint'), **creds)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_boto3/__init__.py", line 94, in client
    return _get_default_session().client(*args, **kwargs)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_boto3/session.py", line 324, in client
    token_manager=token_manager, config=config)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_botocore/session.py", line 900, in create_client
    client_config=config, api_version=api_version)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_botocore/client.py", line 86, in create_client
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_botocore/client.py", line 328, in _get_client_args
    verify, credentials, scoped_config, client_config, endpoint_bridge)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_botocore/args.py", line 85, in get_client_args
    client_cert=new_config.client_cert)
  File "/home/vmorris/.virtualenvs/cos-stuff/lib/python2.7/site-packages/ibm_botocore/endpoint.py", line 261, in create_endpoint
    raise ValueError("Invalid endpoint: %s" % endpoint_url)
ValueError: Invalid endpoint: s3.us-east.cloud-object-storage.appdomain.cloud

Digging into ibm_botocore/endpoint.py, I see the call to is_valid_endpoint_url here: https://github.com/IBM/ibm-cos-sdk-python-core/blob/master/ibm_botocore/utils.py#L831

This does

    parts = urlsplit(endpoint_url)
    hostname = parts.hostname

Looking at urlsplit now... Here's the result of the call to urlsplit:

SplitResult(scheme='', netloc='', path=u's3.us-east.cloud-object-storage.appdomain.cloud', query='', fragment='')

Notice that there is no hostname key in the result.

So, am I doing something wrong?

vmorris commented 5 years ago

eeeh, I just read the docstring:

Must have at least a scheme
        and a hostname.

Disregard please! This appears to be working okay after adding https:// to the endpoint.