Odd CB webpage behavior & C SDK binary / blob document


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                                             |..|

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"}|

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?


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                                             |..|

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.


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@<0.8252.0>:menelaus_web:loop:187]Server error during processing: ["web request failed",

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 https://issues.couchbase.com/browse/MB-26303