{"action":"created","issue":{"url":"https://api.github.com/repos/StackStorm/st2/issues/2906","repository_url":"https://api.github.com/repos/StackStorm/st2","labels_url":"https://api.github.com/repos/StackStorm/st2/issues/2906/labels{/name}","comments_url":"https://api.github.com/repos/StackStorm/st2/issues/2906/comments","events_url":"https://api.github.com/repos/StackStorm/st2/issues/2906/events","html_url":"https://github.com/StackStorm/st2/pull/2906","id":177228807,"number":2906,"title":"[WIP] Add support for Jinja template notation for default parameter values for object parameters","user":{"login":"Kami","id":125088,"avatar_url":"https://avatars.githubusercontent.com/u/125088?v=3","gravatar_id":"","url":"https://api.github.com/users/Kami","html_url":"https://github.com/Kami","followers_url":"https://api.github.com/users/Kami/followers","following_url":"https://api.github.com/users/Kami/following{/other_user}","gists_url":"https://api.github.com/users/Kami/gists{/gist_id}","starred_url":"https://api.github.com/users/Kami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kami/subscriptions","organizations_url":"https://api.github.com/users/Kami/orgs","repos_url":"https://api.github.com/users/Kami/repos","events_url":"https://api.github.com/users/Kami/events{/privacy}","received_events_url":"https://api.github.com/users/Kami/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-15T16:49:07Z","updated_at":"2016-09-15T18:38:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/StackStorm/st2/pulls/2906","html_url":"https://github.com/StackStorm/st2/pull/2906","diff_url":"https://github.com/StackStorm/st2/pull/2906.diff","patch_url":"https://github.com/StackStorm/st2/pull/2906.patch"},"body":"This pull request adds support for using Jinja notation for action default parameter values for parameters of type object.\r\n\r\nThis issue (lack of feature / support for objects) was caught and reported by ferris on Slack.\r\n\r\nHe had an action similar to the one below:\r\n\r\n```yaml\r\n---\r\nname: example\r\npack: examples\r\ndescription: Example\r\nrunner_type: http-request\r\nenabled: true\r\nparameters:\r\n    driveraddress:\r\n        type: string\r\n        required: true\r\n        default: \"10.255.4.15:3000\" \r\n    host:\r\n        type: string\r\n        required: true\r\n    port:\r\n        type: integer\r\n        required: true\r\n    params:\r\n        type: object\r\n        immutable: true\r\n        default:\r\n            host: \"{{host}}\"\r\n            port: \"{{port}}\"\r\n    url:\r\n        type: string\r\n        immutable: true\r\n        default: \"http://{{driveraddress}}/api/gen-payload/ve\"\r\n```\r\n\r\nThis didn't work since default values for `params` parameter was not rendered since existing code didn't support objects.\r\n\r\nThis pull request fixes that and adds support for rendering default parameter values for objects with a single level of nesting (like the one in the example above).\r\n\r\nWe don't support arbitrary level of nesting since this would increase computation time and potentially lead to resource exhaustion, infinite recursion or similar. It's the same story with lists which we already supported - we only render first level items in the list and don't support nested lists.\r\n\r\nNot supporting objects basically means that in a scenario like the one above, user won't be able to leverage the HTTP runner, but they will need to write code for Python runner action or similar.\r\n\r\n## TODO\r\n\r\n- [ ] Tests\r\n- [ ] Changelog"},"comment":{"url":"https://api.github.com/repos/StackStorm/st2/issues/comments/247413845","html_url":"https://github.com/StackStorm/st2/pull/2906#issuecomment-247413845","issue_url":"https://api.github.com/repos/StackStorm/st2/issues/2906","id":247413845,"user":{"login":"code-ape","id":3579192,"avatar_url":"https://avatars.githubusercontent.com/u/3579192?v=3","gravatar_id":"","url":"https://api.github.com/users/code-ape","html_url":"https://github.com/code-ape","followers_url":"https://api.github.com/users/code-ape/followers","following_url":"https://api.github.com/users/code-ape/following{/other_user}","gists_url":"https://api.github.com/users/code-ape/gists{/gist_id}","starred_url":"https://api.github.com/users/code-ape/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/code-ape/subscriptions","organizations_url":"https://api.github.com/users/code-ape/orgs","repos_url":"https://api.github.com/users/code-ape/repos","events_url":"https://api.github.com/users/code-ape/events{/privacy}","received_events_url":"https://api.github.com/users/code-ape/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T18:38:55Z","updated_at":"2016-09-15T18:38:55Z","body":"Attempted to test this change with use-case shown. This will now be accepted when running `st2 run packs.load` however attempting to run the action inside stackstorm results in the following:\r\n\r\n```json\r\n{\r\n  ...,\r\n  \"parameters\": {\r\n    \"host\": \"10.255.4.15\",\r\n    \"driver-address\": \"localhost:3000\",\r\n    \"port\": 22\r\n  },\r\n  \"runner\": {\r\n    \"runner_module\": \"st2actions.runners.httprunner\",\r\n    \"uid\": \"runner_type:http-request\",\r\n    \"enabled\": true,\r\n    \"name\": \"http-request\",\r\n    \"runner_parameters\": {\r\n      ...\r\n    },\r\n    \"id\": \"57d95dc00640fd1e8d6dd431\",\r\n    \"description\": \"A HTTP client for running HTTP actions.\"\r\n  },\r\n  \"web_url\": \"https://vagrant-ubuntu-trusty-64/#/history/57dae8ad0640fd283a76d4c9/general\",\r\n  \"result\": {\r\n    \"traceback\": \"  File \\\"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2api/controllers/v1/actionexecutions.py\\\", line 154, in _schedule_execution\\n    liveaction_db.context)\\n  File \\\"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/param.py\\\", line 218, in render_live_params\\n    _validate(G)\\n  File \\\"/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/param.py\\\", line 139, in _validate\\n    raise ParamException(msg)\\n\",\r\n    \"error\": \"Dependecy unsatisfied for parameter \\\"driver\\\"\"\r\n  },\r\n  \"context\": {\r\n    \"trace_context\": {},\r\n    \"user\": \"st2admin\"\r\n  },\r\n  \"action\": {\r\n    \"runner_type\": \"http-request\",\r\n    \"name\": \"edit_ve_gen_payload\",\r\n    \"parameters\": {\r\n      \"url\": {\r\n        \"default\": \"http://{{ driver-address }}/api/gen-payload/ve\",\r\n        \"type\": \"string\",\r\n        \"immutable\": true\r\n      },\r\n      \"host\": {\r\n        \"required\": true,\r\n        \"type\": \"string\"\r\n      },\r\n      \"driver-address\": {\r\n        \"required\": true,\r\n        \"type\": \"string\"\r\n      },\r\n      \"params\": {\r\n        \"default\": {\r\n          \"host\": \"10.255.4.15\",\r\n          \"port\": 22\r\n        },\r\n        \"type\": \"object\",\r\n        \"immutable\": true\r\n      },\r\n      \"port\": {\r\n        \"required\": true,\r\n        \"type\": \"integer\"\r\n      }\r\n    },\r\n ...\r\n}\r\n```"}}
{"actor":{"display_login":"code-ape"}}