Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-496

cluster_manager() method causes a crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.4.0
    • 2.3.5
    • library
    • None

    Description

      The following code will cause the application to crash:

      from couchbase.cluster import Cluster, PasswordAuthenticator
       
      cluster = Cluster('couchbase://localhost:8091') 
      cluster.authenticate(PasswordAuthenticator('Administrator', 'password'))
       
      admin = cluster.cluster_manager()
      

      Error:

      Traceback (most recent call last):
        File "test.py", line 10, in <module>
          admin = cluster.cluster_manager()
        File "/home/vagrant/couchbase-python-client/couchbase/cluster.py", line 117, in cluster_manager
          return Admin(username, password, connection_string=connection_string)
        File "/home/vagrant/couchbase-python-client/couchbase/admin.py", line 91, in __init__
          super(Admin, self).__init__(**kwargs)
      couchbase.exceptions.NotSupportedError: <RC=0x13[Operation not supported], Couldn't create instance. Either bad credentials/hosts/bucket names were passed, or there was an internal error in creating the object, C Source=(src/bucket.c,923)>
      

      Looking into this further, it seems that this is caused by a mangled connection string, from additional debug information:

      <couchbase.connstr.ConnectionString object at 0x7f3144f59b10>
      couchbase://localhost?/default?ipv6=disabled
      

      This happens because we construct the connstr at https://github.com/couchbase/couchbase-python-client/blob/master/couchbase/connstr.py#L141 and unconditionally put the ? on the end.

      Later we then try to tack the bucket and additional ipv6 query parameter in the Admin constructor: https://github.com/couchbase/couchbase-python-client/blob/master/couchbase/admin.py#L83.

      I think the best way to handle this is to not attempt to add the bucket or extra parameter if the connection_string kwarg has been passed to the constructor.

      Workaround

      If you experience this issue, then you can create the Admin object manually as covered in https://developer.couchbase.com/documentation/server/5.1/sdk/python/managing-clusters.html.

      Example:

      from couchbase.admin import Admin
       
      adm = Admin('Administrator', 'password', host='localhost', port=8091)
      

      Attachments

        Activity

          People

            matt.carabine Matt Carabine (Inactive)
            matt.carabine Matt Carabine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty