{"action":"opened","issue":{"url":"https://api.github.com/repos/hyperledger/composer/issues/4130","repository_url":"https://api.github.com/repos/hyperledger/composer","labels_url":"https://api.github.com/repos/hyperledger/composer/issues/4130/labels{/name}","comments_url":"https://api.github.com/repos/hyperledger/composer/issues/4130/comments","events_url":"https://api.github.com/repos/hyperledger/composer/issues/4130/events","html_url":"https://github.com/hyperledger/composer/issues/4130","id":331154535,"node_id":"MDU6SXNzdWUzMzExNTQ1MzU=","number":4130,"title":"Query with Array parameter fails with \"undefined is a required argument\"","user":{"login":"nicolapaoli","id":31096144,"node_id":"MDQ6VXNlcjMxMDk2MTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/31096144?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolapaoli","html_url":"https://github.com/nicolapaoli","followers_url":"https://api.github.com/users/nicolapaoli/followers","following_url":"https://api.github.com/users/nicolapaoli/following{/other_user}","gists_url":"https://api.github.com/users/nicolapaoli/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolapaoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolapaoli/subscriptions","organizations_url":"https://api.github.com/users/nicolapaoli/orgs","repos_url":"https://api.github.com/users/nicolapaoli/repos","events_url":"https://api.github.com/users/nicolapaoli/events{/privacy}","received_events_url":"https://api.github.com/users/nicolapaoli/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-11T11:44:07Z","updated_at":"2018-06-11T11:44:07Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## Context\r\nReceiving an error when trying to execute a query from the REST Server.\r\nI need to pass an Array as parameter to retrieve all the assets with a field value contained in that array.\r\n\r\nI found the same error was fixed when the parameter was a String [#2539](https://github.com/hyperledger/composer/issues/2539). I am basically looking for the opposite scenario, when the model has a String field (or a reference) and an Array is required as parameter.\r\n\r\n## Steps to Reproduce\r\n\r\nModel File\r\n```\r\nasset Car identified by id {\r\n    o String id\r\n    --> Model model\r\n}\r\nasset Model identifierd by id {\r\n    o String id\r\n    o String name\r\n}\r\n```\r\n\r\nQuery to retrieve all the cars with specified models:\r\n```\r\nquery getCarsByModels {\r\n    statement:\r\n        SELECT ie.example.Car\r\n            WHERE (_$modelArray CONTAINS model)\r\n}\r\n```\r\n## Expected Behavior\r\n\r\nGiven the following Cars:\r\n```\r\n{id: \"car1\", model: \"resource:ie.example.Model#model1\"}\r\n{id: \"car2\", model: \"resource:ie.example.Model#model2\"}\r\n{id: \"car3\", model: \"resource:ie.example.Model#model3\"}\r\n```\r\nIf passing the following parameter:\r\n```\r\nmodelArray = [\"resource:ie.example.Model#model1\", \"resource:ie.example.Model#model2\"]\r\n```\r\n\r\nexpect the endpoint to return the following cars:\r\n```\r\n{id: \"car1\", model: \"resource:ie.example.Model#model1\"}\r\n{id: \"car2\", model: \"resource:ie.example.Model#model2\"}\r\n```\r\n\r\n## Actual Behavior\r\nQuery is built but explorer doesn't show the parameter: \r\n<img width=\"1076\" alt=\"REST Splorer\" src=\"https://user-images.githubusercontent.com/31096144/41226341-13666f06-6d69-11e8-9e8f-22e67e580f41.png\">\r\n\r\nIf querying directly the endpoint, I receive the following error:\r\n```\r\n{\"error\":{\"statusCode\":400,\"name\":\"Error\",\"message\":\"undefined is a required argument\",\"stack\":\"Error: undefined is a required argument\\n    at badArgumentError (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/shared-method.js:291:13)\\n    at validateInputArgument (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/shared-method.js:325:13)\\n    at SharedMethod.invoke (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/shared-method.js:239:16)\\n    at HttpContext.invoke (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/http-context.js:297:12)\\n    at phaseInvoke (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/remote-objects.js:685:9)\\n    at runHandler (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/lib/phase.js:135:5)\\n    at iterate (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/node_modules/async/lib/async.js:146:13)\\n    at Object.async.eachSeries (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/node_modules/async/lib/async.js:162:9)\\n    at runHandlers (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/lib/phase.js:144:13)\\n    at iterate (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/node_modules/async/lib/async.js:146:13)\\n    at /Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/node_modules/async/lib/async.js:157:25\\n    at /Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/node_modules/async/lib/async.js:154:25\\n    at execStack (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/remote-objects.js:530:7)\\n    at RemoteObjects.execHooks (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/remote-objects.js:534:10)\\n    at phaseBeforeInvoke (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/lib/remote-objects.js:681:10)\\n    at runHandler (/Users/nicolapaoli/.nvm/versions/node/v8.11.2/lib/node_modules/composer-rest-server/node_modules/strong-remoting/node_modules/loopback-phase/lib/phase.js:135:5)\"}}\r\n```\r\n\r\n## Possible Fix\r\nFix queryanalyzer to parse CONTAINS when expecting an array as parameter.\r\n\r\n## Existing issues\r\n- [x] [Stack Overflow issues](http://stackoverflow.com/tags/hyperledger-composer)\r\n    - [Query with Array parameter in Hyperledger Composer\r\n](https://stackoverflow.com/questions/50795056/query-with-array-parameter-in-hyperledger-composer)\r\n- [x] [GitHub Issues](https://github.com/hyperledger/composer/issues)\r\n    - [#2539](https://github.com/hyperledger/composer/issues/2539) Same error was fixed when the model field was an Array.\r\n- [x] [Rocket Chat history](https://chat.hyperledger.org/channel/composer)\r\n\r\n## Your Environment\r\n* Version used: v0.19.8\r\n"}}
{"actor":{"display_login":"nicolapaoli"}}