[DOC RN] Invalid JSON reported for valid keys during querying

Description

When getting results from a view using a start key, Couchbase reports:

bad_request (invalid UTF-8 JSON: error,{1,"lexical error: invalid char in json text.\n", "..."})

Steps to reproduce:

1. create a bucket
2. create a new document with key "KEY-1a4b"
3. create a view with the following map function:

function (doc, meta) {
emit(meta.id, doc);
}

4. query the view using the URL:

http://.../test/_design/dev_main/_view/all_documents?stale=false&startkey=KEY-1a4b&connection_timeout=60000&limit=10&skip=0

Components

None

Affects versions

Fix versions

Labels

Environment

Linux Mint 13

Link to Log File, atop/blg, CBCollectInfo, Core dump

None

Release Notes Description

None

Activity

Raju Suravarjjala September 23, 2016 at 9:46 PM

Bulk closing all invalid bugs that are duplicate, user error, invalid. Please feel free to reopen them if you feel otherwise

Maria McDuff April 5, 2013 at 7:23 AM

pls document for 2.0.2. thanks.

Filipe Manana January 21, 2013 at 11:45 AM

Please do note the logic:

startkey and endkey refer to keys that can (are) emitted by the map function, which can only be valid JSON.

key-1a4b is invalid JSON, but "key-1a4b" is valid JSON.

This is often a surprise to users not so familiar with HTTP and JSON. I don't know if it's documented in Couchbase's documentation (couldn't find anything quickly), but in Apache CouchDB's wiki it is very explicit:

http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options

Peter Schönhofen January 21, 2013 at 10:13 AM

It indeed works with quotation marks ("), thanks.

Peter Schönhofen January 21, 2013 at 8:40 AM

I tried but it does not help, the returned error message is the same.

Incomplete
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created January 18, 2013 at 11:45 AM
Updated September 23, 2016 at 9:46 PM
Resolved January 21, 2013 at 11:45 AM
Instabug