Odd CB webpage behavior & C SDK binary / blob document

Hi,

I am starting to explore Couchbase Server (4.6) and the C SDK (v2.8.1) running on Ubuntu 14.04.

My question is the opposite of this post:

I want to store a binary / blob document in the ‘default’ bucket, where my code does the following:

std::string key("imci_cc_code2");
unsigned char dataBytes[] = { 0x0a, 0x0b };

lcb_CMDSTORE scmd = { 0 };
scmd.operation = LCB_SET;
scmd.flags = x; // I think this is for app usage, though I've tried values 0, 1, 2, 3 just in case it means something to CB
LCB_CMD_SET_KEY(&scmd, key.c_str(), key.size());
LCB_CMD_SET_VALUE(&scmd, &dataBytes[0], sizeof(dataBytes));
 
lcb_error_t rc = lcb_store3(instance, NULL, &scmd);

The raw bytes are stored OK:

$ ./build/bin/cbc cat imci_cc_code2 -U couchbase://localhost/default | hd
imci_cc_code2        CAS=0x14eafedeae780000, Flags=0x3. Size=2

00000000  0a 0b                                             |..|
00000002

And I have a second document stored in the ‘default’ bucket that is valid json:

$ ./build/bin/cbc cat bar -U couchbase://localhost/default | hd
bar                  CAS=0x14eaff95d01e0000, Flags=0x0. Size=20

00000000  7b 22 76 61 6c 75 65 22  3a 22 62 61 72 56 61 6c  |{"value":"barVal|
00000010  75 65 22 7d                                       |ue"}|
00000014

But when viewing the “Data Buckets / default / Documents” bucket using the web page, it doesn’t list any documents in the bucket. It simply shows the attached picture which has a read error message that simply says:

“Error: ()”

Is my code wrong?

Thanks!

we don’t recommend to use flags in the application, but if you want to use them, please make sure you follow our flags convention (SDKRFC-20), otherwise the library or anything like UI might behave incorrectly, because it tries to interpret value according to common rules. Could you try your example with zero in flags?

Appreciate the quick response:

I flushed the bucket and then recreated the binary document using “flags = 0”, and it is stored OK as expected:

$ ./build/bin/cbc cat imci_cc_code2 -U couchbase://localhost/default | hd
imci_cc_code2        CAS=0x14eb05de201a0000, Flags=0x0. Size=2

00000000  0a 0b                                             |..|
00000002

But the CB webpage has the same problem as described in my original post: “Error()”.

Any other thoughts or ideas? Looks like a webpage display bug, I guess.

Thanks!

Yes, it looks like a bug on the UI, it uses the following request to display the list of documents (tested on 4.6.3-4136 Enterprise Edition):

$ curl  'http://localhost:8091/pools/default/buckets/default/docs?include_docs=true'
["Unexpected server error, request logged."]

Which in turn logs this on the server side:

[ns_server:error,2017-10-06T19:31:06.065+03:00,ns_1@127.0.0.1:<0.8252.0>:menelaus_web:loop:187]Server error during processing: ["web request failed",
                                 {path,"/pools/default/buckets/default/docs"},
                                 {method,'GET'},
                                 {type,error},
                                 {what,{case_clause,<<"\n\v">>}},
                                 {trace,
                                  [{mochijson2,tokenize,2,
                                    [{file,
                                      "/home/couchbase/jenkins/workspace/watson-unix/couchdb/src/mochiweb/mochijson2.erl"},
                                     {line,547}]},
                                   {mochijson2,decode1,2,
                                    [{file,
                                      "/home/couchbase/jenkins/workspace/watson-unix/couchdb/src/mochiweb/mochijson2.erl"},
                                     {line,326}]},
                                   {mochijson2,json_decode,2,
                                    [{file,
                                      "/home/couchbase/jenkins/workspace/watson-unix/couchdb/src/mochiweb/mochijson2.erl"},
                                     {line,321}]},
                                   {menelaus_web_crud,encode_doc,1,
                                    [{file,"src/menelaus_web_crud.erl"},
                                     {line,163}]},
                                   {menelaus_web_crud,do_handle_limit,3,
                                    [{file,"src/menelaus_web_crud.erl"},
                                     {line,153}]},
                                   {menelaus_web_crud,do_handle_list,4,
                                    [{file,"src/menelaus_web_crud.erl"},
                                     {line,82}]},
                                   {menelaus_web,loop,2,
                                    [{file,"src/menelaus_web.erl"},
                                     {line,163}]},
                                   {mochiweb_http,headers,5,
                                    [{file,
                                      "/home/couchbase/jenkins/workspace/watson-unix/couchdb/src/mochiweb/mochiweb_http.erl"},
                                     {line,94}]}]}]

So the server cannot parse the document as JSON, and returns error. But in fact it should fall back to base64 encoding, which it does not in this case for some reason.

Could you open issue ticket on the server tracker? https://issues.couchbase.com/projects/MB/issues

Thank you for confirming that it is a webserver UI bug.

I’m in the midst of learning & evaluating Couchbase Server, so I’d prefer not to go through the hassle of requesting a JIRA account / etc to create a trouble ticket at this point. Maybe someone else with a JIRA account can do that for now?

Thanks again!

Reported as Loading...