{"action":"opened","issue":{"url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3344","repository_url":"https://api.github.com/repos/couchbase/sync_gateway","labels_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3344/labels{/name}","comments_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3344/comments","events_url":"https://api.github.com/repos/couchbase/sync_gateway/issues/3344/events","html_url":"https://github.com/couchbase/sync_gateway/issues/3344","id":301111473,"number":3344,"title":"Sync Gateway 1.5.1 panics when querying a view","user":{"login":"timritzer","id":7315207,"avatar_url":"https://avatars1.githubusercontent.com/u/7315207?v=4","gravatar_id":"","url":"https://api.github.com/users/timritzer","html_url":"https://github.com/timritzer","followers_url":"https://api.github.com/users/timritzer/followers","following_url":"https://api.github.com/users/timritzer/following{/other_user}","gists_url":"https://api.github.com/users/timritzer/gists{/gist_id}","starred_url":"https://api.github.com/users/timritzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timritzer/subscriptions","organizations_url":"https://api.github.com/users/timritzer/orgs","repos_url":"https://api.github.com/users/timritzer/repos","events_url":"https://api.github.com/users/timritzer/events{/privacy}","received_events_url":"https://api.github.com/users/timritzer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-28T17:24:19Z","updated_at":"2018-02-28T17:24:19Z","closed_at":null,"author_association":"NONE","body":"This occurs on Sync Gateway 1.5.1. We are currently on 1.4.1, and this functionality works fine. This was found while testing for upgrade path due to other bugs fixed in the 1.5 timeframe.\r\n\r\nOccurs on Windows environments. Have tested on Windows 10 as well as Server 2008 R2\r\n\r\nConfiguration:\r\nNothing special on the config, using the provided example for pointing at a real bucket, only changing the URL to our server, and the bucket to our bucket. (Also occurs on other environment with multiple buckets currently running 1.4.1 successfully)\r\n\r\nRelavent Logs\r\nhttps://gist.github.com/timritzer/63899082e218029f7d17bc5fe93c5e9b\r\n\r\nExpected:\r\nExpected the sync to return filtered view results based on the passed in keys.\r\n\r\nWhat Happens:\r\nSync Gateway panics logs errors, and fails to respond to request.\r\n\r\nSteps to reproduce:\r\n\r\n1. Create view through Sync Gateway. We usually do this in the back end application, but for reference created using CURL in windows:\r\n`curl -v -X PUT http://localhost:4985/db/_design/keylookup_withreduce -H \"Content-Type: application/json\" -d \"{ \\\"views\\\": {\\\"keylookup_withreduce\\\": { \\\"map\\\": \\\"function (doc, meta) { if(doc._deleted) { return; } for(var i in doc.channels) { emit(doc.channels[i], doc.keyid);}}\\\" , \\\"reduce\\\": \\\"function (keys, values, rereduce) { if (rereduce) { var result = []; for (var i = 0; i ^< values.length; i++) { var distinct = values[i]; for (var j = 0; j ^< distinct.length; j++){result.push(distinct[j]);}} return result.filter(function (e, i, arr) { return arr.lastIndexOf(e) === i;}); } return values.filter(function (e, i, arr) { return arr.lastIndexOf(e) === i; } );} \\\" }}}\"`\r\n\r\n2. Query view through Sync Gateway. Again, usually done in code, but for purposes of recreation here is a CURL request:\r\n`curl -v http://localhost:4985/db/_design/keylookup_withreduce/_view/keylookup_withreduce?keys=%5B%22env_1%22%5D`\r\n\r\n3. Note that no response is returned, and the error logs show the panic posted in the logs above.\r\n\r\nNote that querying for only one key works as expected, and returns results.\r\n`curl -v http://localhost:4985/db/_design/keylookup_withreduce/_view/keylookup_withreduce?key=%22env_1%22`\r\nAlso querying through Couchbase itself works as well."}}
{"actor":{"display_login":"timritzer"}}