Newline in Key Legal

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Newline in Key Legal

Jim Adler-2
I'm getting a crash when running a key filter query. It looks like the problem is having a newline in a key name (see name-this\nBob in error below).  Is there any restriction on key characters?

Jim

2011-10-24 05:08:14 =SUPERVISOR REPORT====
     Supervisor: {local,riak_pipe_fitting_sup}
     Context:    child_terminated
     Reason:     {sink_died,{sink_died,{json_encode,{bad_term,{not_found,{<<"nodes">>,<<"name-THIS
Bob">>},undefined}}}}}
     Offender:   [{pid,<0.3428.0>},{name,undefined},{mfargs,{riak_pipe_fitting,start_link,undefined}},{restart_type,temporary},{shutdown,2000},{child_type,worker}]


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Newline in Key Legal

Jim Adler-2
Ok, this is a little simpler but I'm not sure how to proceed. When I pull the keys via <bucket>?keys=stream API, I have a key "name-this\nBob". But fetching it gets me a 404 not found error.  I've tried %0D%0A (and other variants) in the API call but no luck.  Any way to delete this errant key?

Jim

From: Jim Adler <[hidden email]>
Date: Mon, 24 Oct 2011 16:04:40 -0700
To: "[hidden email]" <[hidden email]>
Subject: Newline in Key Legal

I'm getting a crash when running a key filter query. It looks like the problem is having a newline in a key name (see name-this\nBob in error below).  Is there any restriction on key characters?

Jim

2011-10-24 05:08:14 =SUPERVISOR REPORT====
     Supervisor: {local,riak_pipe_fitting_sup}
     Context:    child_terminated
     Reason:     {sink_died,{sink_died,{json_encode,{bad_term,{not_found,{<<"nodes">>,<<"name-THIS
Bob">>},undefined}}}}}
     Offender:   [{pid,<0.3428.0>},{name,undefined},{mfargs,{riak_pipe_fitting,start_link,undefined}},{restart_type,temporary},{shutdown,2000},{child_type,worker}]

_______________________________________________ riak-users mailing list [hidden email] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Newline in Key Legal

bryan-basho
Administrator
On Tue, Oct 25, 2011 at 12:54 AM, Jim Adler <[hidden email]> wrote:
> Ok, this is a little simpler but I'm not sure how to proceed. When I pull
> the keys via <bucket>?keys=stream API, I have a key "name-this\nBob". But
> fetching it gets me a 404 not found error.  I've tried %0D%0A (and other
> variants) in the API call but no luck.  Any way to delete this errant key?
> Jim

Hi, Jim.  Just %0A seems to work for me:

$ curl -X PUT -H "content-type: text/plain"
http://localhost:8098/riak/jim/one-two%0Athree --data "hello"

$ curl http://localhost:8098/riak/jim?keys=true
{…"keys":["one-two\nthree"]}

$ curl http://localhost:8098/riak/jim/one-two%0Athree
hello

$ curl -X DELETE http://localhost:8098/riak/jim/one-two%0Athree
$ curl http://localhost:8098/riak/jim/one-two%0Athree
not found

That was on the tip of riak's master branch.  If you're still having
trouble, could you please reply with the Riak version you're using (I
know that 0.14 had an odd encoding behavior that was fixed in 1.0[1]),
as well as your choice of client and a snippet or two of code?

-Bryan

[1] https://issues.basho.com/show_bug.cgi?id=617

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Newline in Key Legal

Jim Adler-2
Hi Bryan - I'm now running 1.0.1 but the keys were inserted under 0.14.  I
tried your test and it worked fine.  So, maybe I'm caught between
inserting under an old version and now reading under another?

Thanks for your help.

Jim
 
On 10/25/11 7:02 AM, "Bryan Fink" <[hidden email]> wrote:

>On Tue, Oct 25, 2011 at 12:54 AM, Jim Adler <[hidden email]> wrote:
>> Ok, this is a little simpler but I'm not sure how to proceed. When I
>>pull
>> the keys via <bucket>?keys=stream API, I have a key "name-this\nBob".
>>But
>> fetching it gets me a 404 not found error.  I've tried %0D%0A (and other
>> variants) in the API call but no luck.  Any way to delete this errant
>>key?
>> Jim
>
>Hi, Jim.  Just %0A seems to work for me:
>
>$ curl -X PUT -H "content-type: text/plain"
>http://localhost:8098/riak/jim/one-two%0Athree --data "hello"
>
>$ curl http://localhost:8098/riak/jim?keys=true
>{Š"keys":["one-two\nthree"]}
>
>$ curl http://localhost:8098/riak/jim/one-two%0Athree
>hello
>
>$ curl -X DELETE http://localhost:8098/riak/jim/one-two%0Athree
>$ curl http://localhost:8098/riak/jim/one-two%0Athree
>not found
>
>That was on the tip of riak's master branch.  If you're still having
>trouble, could you please reply with the Riak version you're using (I
>know that 0.14 had an odd encoding behavior that was fixed in 1.0[1]),
>as well as your choice of client and a snippet or two of code?
>
>-Bryan
>
>[1] https://issues.basho.com/show_bug.cgi?id=617



_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Newline in Key Legal

bryan-basho
Administrator
On Tue, Oct 25, 2011 at 10:35 AM, Jim Adler <[hidden email]> wrote:
> Hi Bryan - I'm now running 1.0.1 but the keys were inserted under 0.14.  I
> tried your test and it worked fine.  So, maybe I'm caught between
> inserting under an old version and now reading under another?

It's possible that your upgraded nodes are operating in compatibility
mode wrt. key decoding, rather than using the 1.0 default behavior.
Look in the riak_kv section of your app.config for the line:

     {http_url_encoding, on},

If that's missing or set to 'compat' instead of 'on', then asking for
"foo%0Abar" over HTTP will attempt to look up "foo%0Abar", not
"foo\nbar".  There are two ways to access this key in 1.0, one
request-level the other global.

The request-level path is to use the X-Riak-URL-Encoding header:

    curl -H "X-Riak-URL-Encoding:on" http://.../foo%0Abar

That will enable the 1.0 decoding behavior for just that request.

The global path is to alter the aforementioned setting in your
app.config and bounce the node.  Note that if you had any keys with
percent signs or other invalid URL characters in them, though, you'll
now have to encode those keys when requesting them (this is the reason
for leaving upgraded nodes in 'compat' mode by default).

-Bryan

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Newline in Key Legal

Jim Adler-2
Hi Bryan - Thanks for the info but no dice. app.config http_url_encoding
is "on" but the key shows as not found.

Anything else I can try?

Jim

On 10/25/11 8:26 AM, "Bryan Fink" <[hidden email]> wrote:

>On Tue, Oct 25, 2011 at 10:35 AM, Jim Adler <[hidden email]> wrote:
>> Hi Bryan - I'm now running 1.0.1 but the keys were inserted under 0.14.
>> I
>> tried your test and it worked fine.  So, maybe I'm caught between
>> inserting under an old version and now reading under another?
>
>It's possible that your upgraded nodes are operating in compatibility
>mode wrt. key decoding, rather than using the 1.0 default behavior.
>Look in the riak_kv section of your app.config for the line:
>
>     {http_url_encoding, on},
>
>If that's missing or set to 'compat' instead of 'on', then asking for
>"foo%0Abar" over HTTP will attempt to look up "foo%0Abar", not
>"foo\nbar".  There are two ways to access this key in 1.0, one
>request-level the other global.
>
>The request-level path is to use the X-Riak-URL-Encoding header:
>
>    curl -H "X-Riak-URL-Encoding:on" http://.../foo%0Abar
>
>That will enable the 1.0 decoding behavior for just that request.
>
>The global path is to alter the aforementioned setting in your
>app.config and bounce the node.  Note that if you had any keys with
>percent signs or other invalid URL characters in them, though, you'll
>now have to encode those keys when requesting them (this is the reason
>for leaving upgraded nodes in 'compat' mode by default).
>
>-Bryan



_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com