jiak interface trouble? missing objects?

Bryan Fink bryan at basho.com
Wed Jan 27 11:44:35 EST 2010


On Wed, Jan 27, 2010 at 11:00 AM, Thomas Heller <info at zilence.net> wrote:
> ...
> Then I ran riak/client/lib/jiak.rb, which when done has created the
> bucket 'foo' and a doc 'my known key'. When I look at that with jiak
> via http directly:
>
> http://127.0.0.1:8098/jiak/foo/my%20known%20key
>
> ...
>
> As you can see object:{} is empty, which obviously means an empty
> object in ruby as well. But when I check with erlang (in the riak
> console):
>
> {ok, C} = riak:client_connect('riak at 127.0.0.1').
> {ok, O} = C:get(<<"foo">>, <<"my known key">>, 1).
> (riak at 127.0.0.1)4> riak_object:get_values(O).
> [{{struct,[{<<"baz">>,<<"good">>},{<<"bar">>,42}]},
>  [[<<"foo">>,<<"84UuyhE4fh68UDmKnQyJvc9LZy2">>,
>    <<"tagged">>]]}]
>
> There are the object values I'd expect { 'baz':'good', 'bar':42 }.
>
> Am I missing something or is jiak just not done yet?
>
> Thanks,
> /thomas

Hi, Thomas.  Jiak is functioning normally - it's just the read mask
getting in your way.  If you grab the schema, I think you'll see:

   $ curl http://localhost:8098/jiak/foo
   {"schema":{"allowed_fields":["bar","baz"],"required_fields":[],"read_mask":[],"write_mask":["bar","baz"]}}

The "read_mask" field being an empty list means that none of the
object's fields are readable (meaning none of them will be included in
the response).  To fix, change the schema to include those fields in
"read_mask":

   $ curl -X PUT -H "content-type: application/json"
http://localhost:8098/jiak/foo --data @-
   {"schema":{"allowed_fields":["bar","baz"],"required_fields":[],"read_mask":["bar","baz"],"write_mask":["bar","baz"]}}
   ^D

After that, the object should come down with the "bar" and "baz"
fields included.

The reason that the schema is not what you expected here is that
jiak.rb recently changed from using the value of allowed_fields to
initialize an unspecified read_mask, to using the value of
required_fields instead.  I'm tracking down the reason for this
change, and will fix in some way to remove this surprise.

-Bryan




More information about the riak-users mailing list