StackStorm / StackStorm/st2

incorrect (?) parsing of extra key=value parameters at end of alias chatops commands

Open
#5,074 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug chatops status:to be verified
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

when providing a string parameter to an alias command (such as - blah {{string_value}} ),
when that input string contains an "=" character - the string value is cut incorrectly assuming the "=" to denote a key:value extra parameter - overriding the required parameter.

STACKSTORM VERSION

st2 3.2.0, on Python 2.7.5

OS, environment, install method

centOS 7 - installation on a single host as described at https://docs.stackstorm.com/install/rhel7.html

Steps to reproduce the problem

have a simple alias:

---
name: "test alias"
action_ref: "core.noop"
description: "test for data structs"
formats:
  - bar {{ someval }}
ack:
  enabled: false
result:
  format: |
      a parameter: {{execution.parameters.someval}}

Bug condition: invoke this alias via chat client with the command:
!bar https://www.foo.com/api/v1?some=url&with=eqchars

Expected Results

Chatbot should return
a parameter: https://www.foo.com/api/v1?some=url&with=eqchars

Actual Results

Chatbot returns:
Command "bar https://www.foo.com/?some=url&with=eqchars" doesn't match format string "bar {{ someval }}"

Extra Info

complex strings with spaces and special characters are handled just fine - except when containing an '='

this issue seems to come from st2/st2common/st2common/models/utils/action_alias_utils.py where extra parameters are parsed before anything else and then cut from the command relying on the condition that it contains a '=' without checking if all other required parameters have been parsed first, effectively cutting the last string parameter from the command and parsing it as extra key:value pair instead of what it's supposed to be.

so my theory - in the example failure - the resulting parameters parsed from the alias command will be :

{"parameters": {
  "https://www.foo.com/?some": "url&with=eqchars" }
}

instead of:

{"parameters": {
  "someval": "https://www.foo.com/?some=url&with=eqchars" }
}

Hope that helps...

Thanks!

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 with st2/st2common/st2common/models/utils/action_alias_utils.py and reproduce the alias command using the URL containing embedded '=' characters. Trace how extra parameters are parsed relative to required parameters; done means the alias preserves the complete URL as someval and returns the expected result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.