StackStorm/st2

st2client windows json parsing problems for create apikeys

philipphomberger opened this issue · 3 comments

SUMMARY

Provide a quick summary of your bug report.

STACKSTORM VERSION

Paste the output of st2 --version:
3.8.1

OS, environment, install method

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

  • e.g. Docker, Vagrant, Kubernetes, etc. Describe how you installed ST2
  • e.g. one-line install, custom install, etc -->

The Client is a Windows 10.

Steps to reproduce the problem

Show how to reproduce the problem, using a minimal test-case. Make sure to include any content
(pack content - workflows, actions, etc.) which are needed to reproduce the problem.

(st2) PS C:\Program Files\Python38\st2> st2 apikey create -m '{"used_by": "bootcamptest"}'

Expected Results

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

I espect a new api key is create with that metadata.

Actual Results

What happened? What output did you get?

usage: st2 apikey create [-h] [-t TOKEN] [--api-key API_KEY] [-j] [-y] [-u USER] [-m METADATA] [-k]
st2 apikey create: error: argument -m/--metadata: invalid loads value: '{used_by: bootcamptest}'

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

Thanks!

nzlosh commented

It's not completely clear why, but Python on Windows seems to need escaping for the double quotes " to work: e.g. st2 apikey create -m '{\"used_by\": \"bootcamptest\"}'. This isn't the case with echo. Also cmd.exe has different behaviour to string escaping compared to PowerShell, so some experimentation will be necessary depending on which shell is being used.

Thank you for the Feedback. I will make some research.