Skip to content

Shell script action not serializing array properly. #4804

@kingsleyadam

Description

@kingsleyadam

SUMMARY

According to the documentation (https://docs.stackstorm.com/actions.html#update-argument-parsing-in-the-script), arrays should be passed to bash script actions as a comma-delimited string.

array - Serialized as a comma delimited string (e.g. foo,bar,baz).

But it's coming through as a python list serialized into a string.

[u'foo', u'bar', u'baz']

STACKSTORM VERSION

Paste the output of st2 --version:

stanley@st2-dev:~$ st2 --version
st2 3.1.0, on Python 2.7.12
OS, environment, install method

Post what OS you are running this on, along with any other relevant information.

Ubuntu 16.04 LTS installed via apt packaging.

Steps to reproduce the problem

Example Action YAML File

---
name: "test_bash_array"
runner_type: "remote-shell-script"
description: "Tests an array passed to a bash script."
enabled: true
entry_point: "test_bash_array.sh"
parameters:
    test_array:
        type: "array"
        description: "Test array in bash"
        position: 0

Example Action Bash Script

#!/usr/bin/env bash

TEST_ARRAY=$1

IFS=","; for i in ${TEST_ARRAY}; do echo "$i"; done

exit 0

Invoking Action

test_array:
  - foo
  - bar
  - baz

Expected Results

What did you expect to happen when running the steps above?

Given the above bash script, I'd expect

foo
bar
baz

Actual Results

What happened? What output did you get?

Instead I'm getting

[u'foo'
 u'bar'
 u'baz']

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions