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

Run Job Webhook Plugin - options set from JSON become invalid JSON strings #8989

Open
jyanko opened this issue Mar 8, 2024 · 0 comments
Open

Comments

@jyanko
Copy link

jyanko commented Mar 8, 2024

Describe the bug

When Run Job webhook handler sets an option variable (ie: RD_OPTION_FILES_ADDED) from an incoming JSON payload, quotes around the items in a list appear to be lost, resulting in a string that is un-parsable by downstream json utilities (ie: python's json.loads(json_string)).

Sample input JSON

{
  "head_commit": {
    "added": [
      "file1.txt",
      "file2.txt"
    ]
  }
}

Sample output (string value stored in RD_OPTION_FILES_ADDED variable)

[file1.txt,file2.txt]

Attempting to parse the string stored in the RD_OPTION variable fails due to the missing quotes, similar to the following example

❯ VAR='[file1.txt,file2.txt]'
❯ echo $VAR | jq .
parse error: Invalid literal at line 1, column 11

❯ VAR='["file1.txt","file2.txt"]'
❯ echo $VAR | jq .
[
  "file1.txt",
  "file2.txt"
]

My Rundeck detail

  • Rundeck version: 4.15.0-20230725
  • install type: docker
  • OS Name/version: ubuntu 20.04
  • DB Type/version: mysql

To Reproduce
Steps to reproduce the behavior:

  1. create a webhook which uses the 'Run Job' handler, and sets an RD_OPTION variable from a list element from the incoming json payload
  2. in a job step, attempt to parse the resulting RD_OPTION var that was created with a json utility such as jq or python's json.loads(json_string)
  3. send payload to the webhook like {"head_commit": {"added": ["file1.txt","file2.txt"]}}
  4. observe job results:
    a. RD_OPTION var that was set does not contain the quotes around list items
    b. job fails due to failure to parse json string

Expected behavior
Expect that the RD_OPTION value actually be the captured string - including any quotes it had to start with

Screenshots
If applicable, add screenshots to help explain your problem.

For a payload including list of files as follows...
{"head_commit": {"modified": ["usr-behavior-aggregation/github-notification/pr_reminder.py"]}}

The results as seen in Rundeck UI for the values captured appear as follows...
image

Desktop (please complete the following information):

  • OS: macOS v13.6.4
  • Browser: Chrome
  • Version: 122.0.6261.94 (Official Build) (arm64)

Additional context
n/a

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

No branches or pull requests

1 participant