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
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.5
    • 2.4.0
    • 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

        For Gerrit Dashboard: PYCBC-496
        # Subject Branch Project Status CR V

        Activity

          matt.carabine Matt Carabine created issue -
          matt.carabine Matt Carabine made changes -
          Field Original Value New Value
          Description The following code will cause the application to crash:

          {code:python}
          from couchbase.cluster import Cluster, PasswordAuthenticator

          cluster = Cluster('couchbase://localhost:8091&#39;)
          cluster.authenticate(PasswordAuthenticator('Administrator', 'password'))

          admin = cluster.cluster_manager()
          {code}

          Error:

          {noformat}
          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)>
          {noformat}

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

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

          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:

          {code:python}
          from couchbase.admin import Admin

          adm = Admin('Administrator', 'password', host='localhost', port=8091)
          {code}


          matt.carabine Matt Carabine made changes -
          Link This issue depends on CBSE-5354 [ CBSE-5354 ]
          Ellis.Breen Ellis Breen made changes -
          Status New [ 10003 ] Open [ 1 ]
          Ellis.Breen Ellis Breen made changes -
          Fix Version/s 2.4.1 [ 15210 ]
          Ellis.Breen Ellis Breen made changes -
          Assignee Matt Carabine [ matt.carabine ] Ellis Breen [ ellis.breen ]
          Ellis.Breen Ellis Breen made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Ellis.Breen Ellis Breen made changes -
          Assignee Ellis Breen [ ellis.breen ] Matt Carabine [ matt.carabine ]
          matt.carabine Matt Carabine made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Closed [ 6 ]

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty