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

Version 3 needs access to bucket "default" to connect

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0
    • 3.0.1
    • None
    • Python library 3.0.0
    • 1

    Description

      Old Python library supported a way to authenticate when there were arbitrary bucket names. When there is only bucket 'bucket-name', I can still use this with version 2.5

      >>> from couchbase.cluster import Cluster, PasswordAuthenticator
      >>> cluster = Cluster('couchbase://localhost')
      >>> cluster.authenticate(PasswordAuthenticator('username', 'password'))
      >>> bucket = cluster.open_bucket('bucket-name')

      That works perfectly fine.

      However, when I try the example from version 3.0

      >>> from couchbase.cluster import Cluster, PasswordAuthenticator, ClusterOptions
      >>> from couchbase.auth import PasswordAuthenticator
      >>> cluster = Cluster('couchbase://localhost', ClusterOptions(PasswordAuthenticator('username', 'password')))
      >>> bucket = cluster.bucket('bucket-name')
      >>> collection = bucket.default_collection()

      it fails on line with Cluster() and URI. It tries to connect to bucket "default" based on couchbase/management/admin.py:87. Its caller in couchbase/cluster.py:518 doesn't allow specification of the bucket. That is called from couchbase/cluster.py:533.

      Request: please add a way to connect when there is no "default" bucket.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          Ellis.Breen Ellis Breen added a comment -

          Hi this sounds like an issue that we fixed a week or two ago, and should be in 3.0.0 (non-beta). Please could you send the stack trace and details of the version installed? 

          Ellis.Breen Ellis Breen added a comment - Hi this sounds like an issue that we fixed a week or two ago, and should be in 3.0.0 (non-beta). Please could you send the stack trace and details of the version installed? 
          petoju@gmail.com Peter J added a comment - - edited

          Hi, thanks for the quick reply. I had the latest version from pip, ie. 3.0.0.

          The issue is certainly present in current master and I tried to describe the steps to get to it.

          Stacktrace is here:

          Traceback (most recent call last):
            File "/home/ubuntu/test.py", line 31, in get_cb
              cb = cluster.bucket(bucket)
            File "/home/ubuntu/.local/lib/python3.6/site-packages/couchbase/cluster.py", line 480, in bucket
              return self._cluster.open_bucket(name, admin=self._admin)
            File "/home/ubuntu/.local/lib/python3.6/site-packages/couchbase/cluster.py", line 465, in _admin
              self.__admin = Admin(connection_string=str(self.connstr), **self._adminopts)
            File "/home/ubuntu/.local/lib/python3.6/site-packages/couchbase/management/admin.py", line 101, in __init__
              self._connect()
          couchbase.exceptions.BucketNotFoundException: <RC=0xD2[LCB_ERR_BUCKET_NOT_FOUND (210)], There was a problem while trying to send/receive your request over the network. This may be a result of a bad network or a misconfigured client or server, C Source=(src/bucket.c,1209)>
          
          

           

          Note that the referenced bucket does exist. As I mentioned, the important point is execution of couchbase/management/admin.py and its line 87, that sets the default bucket, that doesn't exist. If it could find the bucket somehow, it could end with better result.

          petoju@gmail.com Peter J added a comment - - edited Hi, thanks for the quick reply. I had the latest version from pip, ie. 3.0.0. The issue is certainly present in current master and I tried to describe the steps to get to it. Stacktrace is here: Traceback (most recent call last): File "/home/ubuntu/test.py", line 31, in get_cb cb = cluster.bucket(bucket) File "/home/ubuntu/.local/lib/python3.6/site-packages/couchbase/cluster.py", line 480, in bucket return self._cluster.open_bucket(name, admin=self._admin) File "/home/ubuntu/.local/lib/python3.6/site-packages/couchbase/cluster.py", line 465, in _admin self.__admin = Admin(connection_string=str(self.connstr), **self._adminopts) File "/home/ubuntu/.local/lib/python3.6/site-packages/couchbase/management/admin.py", line 101, in __init__ self._connect() couchbase.exceptions.BucketNotFoundException: <RC=0xD2[LCB_ERR_BUCKET_NOT_FOUND (210)], There was a problem while trying to send/receive your request over the network. This may be a result of a bad network or a misconfigured client or server, C Source=(src/bucket.c,1209)>   Note that the referenced bucket does exist. As I mentioned, the important point is execution of couchbase/management/admin.py and its line 87, that sets the default bucket, that doesn't exist. If it could find the bucket somehow, it could end with better result.
          Ellis.Breen Ellis Breen added a comment - - edited

          Ah, thanks for the backtrace, I think I just spotted the issue (similar to the one we fixed before). Will produce a PR tomorrow for you to try.

          Ellis.Breen Ellis Breen added a comment - - edited Ah, thanks for the backtrace, I think I just spotted the issue (similar to the one we fixed before). Will produce a PR tomorrow for you to try.
          Ellis.Breen Ellis Breen added a comment - - edited

          Hi, this turned out to be quite a complex issue to fix while keeping our tests happy, but we have just merged a fix for this to the master, which is installable from git via:

           

          pip install git+http://github.com/couchbase-python-client.git
          

          (from http://review.couchbase.org/c/couchbase-python-client/+/127641 )

          Note that this requires a bucket to be opened prior to performing Admin operations on <6.5 clusters, just this bucket can have any name. We may refine this later for <6.5 clusters where possible. Please try this and let us know how you get on, thanks!

          Ellis.Breen Ellis Breen added a comment - - edited Hi, this turned out to be quite a complex issue to fix while keeping our tests happy, but we have just merged a fix for this to the master, which is installable from git via:   pip install git+http: //github.com/couchbase-python-client.git (from http://review.couchbase.org/c/couchbase-python-client/+/127641 ) Note that this requires a bucket to be opened prior to performing Admin operations on <6.5 clusters, just this bucket can have any name. We may refine this later for <6.5 clusters where possible. Please try this and let us know how you get on, thanks!

          People

            david.kelly David Kelly
            petoju@gmail.com Peter J
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty