{"action":"created","issue":{"url":"https://api.github.com/repos/remyla/damas-core/issues/166","repository_url":"https://api.github.com/repos/remyla/damas-core","labels_url":"https://api.github.com/repos/remyla/damas-core/issues/166/labels{/name}","comments_url":"https://api.github.com/repos/remyla/damas-core/issues/166/comments","events_url":"https://api.github.com/repos/remyla/damas-core/issues/166/events","html_url":"https://github.com/remyla/damas-core/issues/166","id":196227003,"number":166,"title":"server-nodejs crash","user":{"login":"remyla","id":1528550,"avatar_url":"https://avatars.githubusercontent.com/u/1528550?v=3","gravatar_id":"","url":"https://api.github.com/users/remyla","html_url":"https://github.com/remyla","followers_url":"https://api.github.com/users/remyla/followers","following_url":"https://api.github.com/users/remyla/following{/other_user}","gists_url":"https://api.github.com/users/remyla/gists{/gist_id}","starred_url":"https://api.github.com/users/remyla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remyla/subscriptions","organizations_url":"https://api.github.com/users/remyla/orgs","repos_url":"https://api.github.com/users/remyla/repos","events_url":"https://api.github.com/users/remyla/events{/privacy}","received_events_url":"https://api.github.com/users/remyla/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-17T15:22:42Z","updated_at":"2016-12-18T21:20:43Z","closed_at":null,"body":"when performing this read:\r\n\r\n$ damas read tests/test4\r\n\r\nGET /api/verify/ 200 2.679 ms - 216\r\n[ '/tests/test4' ]\r\n\r\n/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/utils.js:99\r\n    process.nextTick(function() { throw err; });\r\n                                        ^\r\nTypeError: Cannot read property 'length' of undefined\r\n    at /home/primcode/bin/damas-core/server-nodejs/db/mongodb.js:117:51\r\n    at Array.reduce (native)\r\n    at /home/primcode/bin/damas-core/server-nodejs/db/mongodb.js:115:39\r\n    at handleCallback (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/utils.js:96:56)\r\n    at /home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/cursor.js:853:16\r\n    at handleCallback (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:172:5)\r\n    at setCursorDeadAndNotified (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:507:3)\r\n    at nextFunction (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:655:7)\r\n    at Cursor.next [as _next] (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/node_modules/mongodb-core/lib/cursor.js:696:3)\r\n    at fetchDocs (/home/primcode/bin/damas-core/server-nodejs/node_modules/mongodb/lib/cursor.js:849:10)\r\n"},"comment":{"url":"https://api.github.com/repos/remyla/damas-core/issues/comments/267847538","html_url":"https://github.com/remyla/damas-core/issues/166#issuecomment-267847538","issue_url":"https://api.github.com/repos/remyla/damas-core/issues/166","id":267847538,"user":{"login":"remyla","id":1528550,"avatar_url":"https://avatars.githubusercontent.com/u/1528550?v=3","gravatar_id":"","url":"https://api.github.com/users/remyla","html_url":"https://github.com/remyla","followers_url":"https://api.github.com/users/remyla/followers","following_url":"https://api.github.com/users/remyla/following{/other_user}","gists_url":"https://api.github.com/users/remyla/gists{/gist_id}","starred_url":"https://api.github.com/users/remyla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remyla/subscriptions","organizations_url":"https://api.github.com/users/remyla/orgs","repos_url":"https://api.github.com/users/remyla/repos","events_url":"https://api.github.com/users/remyla/events{/privacy}","received_events_url":"https://api.github.com/users/remyla/received_events","type":"User","site_admin":false},"created_at":"2016-12-18T21:20:43Z","updated_at":"2016-12-18T21:20:43Z","body":"Here is the debug result:\r\n\r\n\"/tests/test4\" is exactly 12 bytes and for some reasons mongoDB ObjectID.isValid(\"/tests/test4\") returns true.\r\n\r\nHere are some discussions about this issue:\r\n\r\nhttps://github.com/Automattic/mongoose/issues/1959\r\nhttp://stackoverflow.com/questions/11985228/mongodb-node-check-if-objectid-is-valid\r\n\r\nreplacing\r\n-        if (ObjectID.isValid(id)) {\r\n\r\nwith this (testing if it is exactly a 24 hex)\r\n+        if (/^[a-fA-F0-9]{24}$/.test(id) && ObjectID.isValid(id)) {\r\nfixes the issue\r\n"}}
{"actor":{"display_login":"remyla"}}