a python sdk bug to query with a loooong key

Hi,

Sorry for posting it here, because currently the web site doesn't allow me to post it to the python client issues...

When I use python sdk 1.1.0 with couchbase 2.2.0 and execute
rows = ct.query('a', 'path', key='012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789', limit=1, stale='false')
for i in rows:
print i

It will generate an error:

HTTPError: <Key='_design/a/_view/path?stale=false&limit=1&key=%22012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789%22', HTTP Request failed. Examine 'objextra' for full result, C Source=(src/http.c,241), OBJ=HttpResult<RC=0x0, Value={u'reason': u'invalid UTF-8 JSON: {{error,{9,"lexical error: invalid char in json text.\\n"}},\n <<"{\\"keys\\":None}">>}', u'error': u'bad_request'}, HTTP=400, URL=_design/a/_view/path?stale=false&limit=1&key=%22012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789%22>>

I tried the same query using the web interface of couchbase, and it returned correct results.

You can change the key to anything else. If the length is more than 150, the bug will be triggered.

thanks,

Lenx

2 Answers

« Back to question.

Hello,

Thanks for raising this, I have logged an issue in our JIRA and you can follow up:
http://www.couchbase.com/issues/browse/PYCBC-203

Regards
Tug
@tgra

« Back to question.

https://github.com/couchbase/couchbase-python-client/commit/b4b260a3c999...

the issue is that when your querystring has a lenght of more then 200 it make a POST request and move the keys to the post data. there is currently a bug when there is no keys. it add a keys=None to the post data.

i havent tested your query but you could try requesting "keys" rather then "key" or apply the fix i have in the post above till 1.2.0 or a patch is release