Skip to content
This repository was archived by the owner on Aug 13, 2026. It is now read-only.
This repository was archived by the owner on Aug 13, 2026. It is now read-only.

Error when generating object keys [JIRA: CLIENTS-900] #484

Description

@linkdd

Using riak 2.1.4 with the python client 2.5.3 with Python 3.4.3:

from riak import RiakClient

c = RiakClient(nodes=[{
    'host': '127.0.0.1',
    'pb_port': '8087'
}])

maps = c.bucket_type('maps')

nodes = maps.bucket('nodes')

node = nodes.new()  # expecting key to be generated by riak
# ...
node.store()

It seems that the generated key is of type bytes instead of str in Python3:

Traceback (most recent call last):
  File "graph.py", line 77, in <module>
    node.store()
  File "/home/linkdd/devel/projects/link-framework/venv3/lib/python3.4/site-packages/riak/datatypes/datatype.py", line 165, in update
    self.bucket._client.update_datatype(self, **params)
  File "/home/linkdd/devel/projects/link-framework/venv3/lib/python3.4/site-packages/riak/client/operations.py", line 1143, in update_datatype
    include_context=include_context)
  File "/home/linkdd/devel/projects/link-framework/venv3/lib/python3.4/site-packages/riak/transports/tcp/transport.py", line 505, in update_datatype
    msg = codec.encode_update_datatype(datatype, **kwargs)
  File "/home/linkdd/devel/projects/link-framework/venv3/lib/python3.4/site-packages/riak/codecs/pbuf.py", line 1211, in encode_update_datatype
    req.key = str_to_bytes(datatype.key)
  File "/home/linkdd/devel/projects/link-framework/venv3/lib/python3.4/site-packages/riak/util.py", line 118, in str_to_bytes
    return value.encode(encoding)
AttributeError: 'bytes' object has no attribute 'encode'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions