{"action":"closed","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1695","repository_url":"https://api.github.com/repos/strongloop/loopback","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1695/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1695/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1695/events","html_url":"https://github.com/strongloop/loopback/issues/1695","id":107927624,"number":1695,"title":"Apparent bug in Strongloop API","user":{"login":"daveland2","id":12873211,"avatar_url":"https://avatars.githubusercontent.com/u/12873211?v=3","gravatar_id":"","url":"https://api.github.com/users/daveland2","html_url":"https://github.com/daveland2","followers_url":"https://api.github.com/users/daveland2/followers","following_url":"https://api.github.com/users/daveland2/following{/other_user}","gists_url":"https://api.github.com/users/daveland2/gists{/gist_id}","starred_url":"https://api.github.com/users/daveland2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daveland2/subscriptions","organizations_url":"https://api.github.com/users/daveland2/orgs","repos_url":"https://api.github.com/users/daveland2/repos","events_url":"https://api.github.com/users/daveland2/events{/privacy}","received_events_url":"https://api.github.com/users/daveland2/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback/labels/triage","name":"triage","color":"eb6420"}],"state":"closed","locked":false,"assignee":{"login":"loay","id":1986928,"avatar_url":"https://avatars.githubusercontent.com/u/1986928?v=3","gravatar_id":"","url":"https://api.github.com/users/loay","html_url":"https://github.com/loay","followers_url":"https://api.github.com/users/loay/followers","following_url":"https://api.github.com/users/loay/following{/other_user}","gists_url":"https://api.github.com/users/loay/gists{/gist_id}","starred_url":"https://api.github.com/users/loay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loay/subscriptions","organizations_url":"https://api.github.com/users/loay/orgs","repos_url":"https://api.github.com/users/loay/repos","events_url":"https://api.github.com/users/loay/events{/privacy}","received_events_url":"https://api.github.com/users/loay/received_events","type":"User","site_admin":false},"assignees":[{"login":"loay","id":1986928,"avatar_url":"https://avatars.githubusercontent.com/u/1986928?v=3","gravatar_id":"","url":"https://api.github.com/users/loay","html_url":"https://github.com/loay","followers_url":"https://api.github.com/users/loay/followers","following_url":"https://api.github.com/users/loay/following{/other_user}","gists_url":"https://api.github.com/users/loay/gists{/gist_id}","starred_url":"https://api.github.com/users/loay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loay/subscriptions","organizations_url":"https://api.github.com/users/loay/orgs","repos_url":"https://api.github.com/users/loay/repos","events_url":"https://api.github.com/users/loay/events{/privacy}","received_events_url":"https://api.github.com/users/loay/received_events","type":"User","site_admin":false}],"milestone":null,"comments":10,"created_at":"2015-09-23T14:06:26Z","updated_at":"2016-09-20T17:18:17Z","closed_at":"2016-09-20T17:18:17Z","body":"This note contains a description of an apparent bug in the Strongloop API.\r\n\r\nThe following query filter when entered into the Strongloop API Explorer crashes the API server:\r\n\r\n{\"where\":{\"id\":3},\"fields\":[\"courname\",\"teacherid\"],\"include\":{\"relation\":\"teachers\",\"scope\":{\"fields\":\"teachername\"}}}\r\n\r\nThe error message that is reported is the following:\r\n\r\nC:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\lib\\include.js:756\r\n            var objList = objTargetIdMap[targetId.toString()];\r\n                                                 ^\r\nTypeError: Cannot read property 'toString' of undefined\r\n    at linkOneToMany (C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\lib\\include.js:756:50)\r\n    at C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:157:13\r\n    at _each (C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:57:9)\r\n    at Object.async.each (C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:156:9)\r\n    at targetLinkingTask (C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\lib\\include.js:753:17)\r\n    at C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:723:21\r\n    at C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:391:17\r\n    at C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:157:13\r\n    at _each (C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:57:9)\r\n    at async.each (C:\\BrickWire\\API\\tests\\node_modules\\loopback-datasource-juggler\\node_modules\\async\\lib\\async.js:156:9)\r\n\r\nIt seems that it should not be possible for an end user to formulate a query that crashes the server (no matter how ill formed the query may be).\r\n\r\nHowever, the following query does NOT crash the server:\r\n\r\n{\"where\":{\"id\":3},\"fields\":[\"courname\",\"teacherid\"],\"include\":{\"relation\":\"teachers\",\"scope\":{\"fields\":[\"teachername\"]}}}\r\n\r\nThe only difference is that the fields filter for teachername in the teachers model is enclosed within square brackets.  (It would seem that the square brackets should not be necessary since there is only a single value, rather than a list of values.)\r\n\r\nNote:  although this query does not crash the server, it also does NOT limit the retrieved fields for the teachers model to be only teachername.  It also displays the id field for the teachers model.  Is this because the id value needs to be present in order to link the teachers model to the courses model?\r\n"}}
{"actor":{"display_login":"loay"}}