StackStorm / StackStorm/st2

Passing an array as parameter does not seem to work

Open
#3,210 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

---
version: "2.0"

my_application.deploy:
  description: "Workflow to deploy an application"
  type: direct
  input:
    - repo_url
    - server_application
    - server_role
    - server_environment
  output:
    stdout: <% $.stdout %>
  tasks:
    get_hosts:
      action: my_core.get_hosts
      input:
        application: <% $.server_application %>
        role: <% $.server_role %>
        environment: <% $.server_environment %>
      publish:
        hosts: <% task(get_hosts).result.result %>
    update:
      action: my_application.update
      input:
        repo_url: <% $.repo_url %>
        hosts: <% $.hosts %>
      publish:
        stdout: <% task(update).result.stdout %>
        stderr: <% task(update).result.stderr %>

But I get the following error:

{
  "tasks": [
    {
      "state_info": null,
      "name": "get_hosts",
      "created_at": "2017-02-10 12:25:16.857967",
      "updated_at": "2017-02-10 12:25:18.358841",
      "id": "61c7d3f2-3c2a-446a-b431-dd92810fc75a",
      "workflow_execution_id": "ff091ab0-d693-4119-ade2-1d5d344d6439",
      "state": "SUCCESS",
      "result": {
        "stdout": "",
        "exit_code": 0,
        "stderr": "",
        "result": [
          "orchestration-orchestrator-01p.adinfra.example.com"
        ]
      },
      "published": {
        "hosts": [
          "orchestration-orchestrator-01p.adinfra.example.com"
        ]
      },
      "input": null,
      "workflow_name": "my_application.deploy"
    },
    {
      "state_info": "Can not evaluate YAQL expression:  $.hosts , data = {u'server_application': u'orchestration', u'repo_url': u...",
      "name": "update",
      "created_at": "2017-02-10 12:25:16.871725",
      "updated_at": "2017-02-10 12:25:16.877147",
      "id": "b23600e9-a23b-494d-92dd-4d4d214d6d43",
      "workflow_execution_id": "ff091ab0-d693-4119-ade2-1d5d344d6439",
      "state": "ERROR",
      "result": [],
      "published": {},
      "input": null,
      "workflow_name": "my_application.deploy"
    }
  ],
  "extra": {
    "state_info": "Failed to start task [task_ex=TaskExecution {'state_info': \"Can not evaluate YAQL expression:  $.hosts , data = {u'server_application': u'orchestration', u'repo_url': u's...",
    "state": "ERROR"
  }
}

Everything works fine if I hard code the hosts in the workflow:

update:
     action: my_application.update
     input:
       repo_url: <% $.repo_url %>
       hosts: ['somehost.example', 'anotherhost.example']

The hosts parameter of the update action is of type "array". But why doesn’t it work when I use the variable <% $.hosts %> ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the workflow shown in the issue, focusing on the published hosts value from get_hosts and its use in the update task. Investigate the YAQL evaluation error and verify completion when the array-valued variable is accepted as the action input rather than requiring hard-coded hosts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.