Unhandled exception when trying to print PathNotFoundException

We currently receive the following traceback when trying to print that error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/couchbase/result.py", line 140, in _parse_content_at_index
    raise PathNotFoundException(
couchbase.exceptions.PathNotFoundException: <unprintable PathNotFoundException object>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "__main__", line 10, in __main__
  File "/usr/local/lib/python3.10/site-packages/couchbase/exceptions.py", line 389, in __str__
AttributeError: 'str' object has no attribute 'err'


  • Server side:
    • CouchBase 6.6.5, official image
  • Client side:
    • Linux Alpine 3.17
    • Python 3.10.10
    • Python SDK 4.1.3, built from source

Minimal code example:

cluster = Cluster(COUCHBASE_URI, ClusterOptions(
    PasswordAuthenticator(COUCHBASE_USER, COUCHBASE_PASS),
    # New client tries to fetch DNS SRV record when supplied with just one host

col = cluster.bucket(COUCHBASE_BUCKET).default_collection()
col.insert("key", {"attr": "value"})

res = col.lookup_in("key", [subdocument.get("notexist")]
  val = res.content_as[str](0)
except PathNotFoundException as why:
  print(str(why))  # this raises an exception

A problem is that the CouchbaseException __init__ method signature changed in Python client 4.x, but some client code still raises exceptions as raise PathNotFoundException("message"), while the first positional argument must not be a string.

Hi @vkhoroz – I have created PYCBC-1475 to address this issue with some of the Python SDK exceptions (I know some of them handle the first positional arg being a string correctly, but as you have found, not all will). Will post once again when the PYCBC has been addressed.

1 Like

Hi @vkhoroz - PYCBC-1475 has been implemented. Hopefully have version 4.1.4 of the SDK released late next week.

Feel free to grab the latest from Github in the interim.

1 Like

Thank you, Jared @jcasey !

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.