Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell script action not serializing array properly. #4804

Closed
kingsleyadam opened this issue Oct 17, 2019 · 3 comments · Fixed by #4861
Closed

Shell script action not serializing array properly. #4804

kingsleyadam opened this issue Oct 17, 2019 · 3 comments · Fixed by #4861
Labels

Comments

@kingsleyadam
Copy link
Contributor

kingsleyadam commented Oct 17, 2019

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!

@blag blag added the bug label Oct 18, 2019
@mweinberg-cm
Copy link

mweinberg-cm commented Feb 11, 2020

I'm working on this issue and am close to come up with a PR or maybe some implementation details to be discussed soon.

@winem
Copy link
Contributor

winem commented Feb 11, 2020

@kingsleyadam the PR is there. I expect some feedback from the more experienced developers and maybe a bit of ping-pong but we should have the fix soon.

And congratulations - you found a bug that is bigger than it actually seemed to be!

@kingsleyadam
Copy link
Contributor Author

Thank you @winem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants