Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
linkdd opened this issue Jun 21, 2016 · 3 comments
Open

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

linkdd opened this issue Jun 21, 2016 · 3 comments

Comments

@linkdd
Copy link
Contributor

linkdd commented Jun 21, 2016

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'
@Basho-JIRA Basho-JIRA changed the title Error when generating object keys Error when generating object keys [JIRA: CLIENTS-900] Jun 21, 2016
@lukebakken lukebakken added this to the riak-python-client-2.6.0 milestone Jun 21, 2016
@lukebakken lukebakken self-assigned this Jun 21, 2016
@lukebakken
Copy link
Contributor

Hello -

Could you please run this command and provide the output in a response?

riak-admin bucket-type status maps

Thanks. I'd like to see how the maps bucket type is configured.

@linkdd
Copy link
Contributor Author

linkdd commented Jun 21, 2016

Here is the output:

maps is active

young_vclock: 20
w: quorum
small_vclock: 50
rw: quorum
r: quorum
pw: 0
precommit: []
pr: 0
postcommit: []
old_vclock: 86400
notfound_ok: true
n_val: 3
linkfun: {modfun,riak_kv_wm_link_walker,mapreduce_linkfun}
last_write_wins: false
dw: quorum
dvv_enabled: true
chash_keyfun: {riak_core_util,chash_std_keyfun}
big_vclock: 50
basic_quorum: false
allow_mult: true
datatype: map
active: true
claimant: '[email protected]'

FYI, I followed the documentation when creating the bucket:

$ riak-admin bucket-type create maps '{"props":{"datatype":"map"}}'
$ riak-admin bucket-type activate maps

@lukebakken
Copy link
Contributor

OK. I asked because there is an integration test that tests a Riak-generated key on a non-datatype bucket, but I couldn't find something for a bucket configured for a datatype. I suspect that's the issue.

@lukebakken lukebakken added this to the riak-python-client-2.7.1 milestone Dec 16, 2016
@lukebakken lukebakken modified the milestones: riak-python-client-2.7.1, riak-python-client-3.0.0 Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants