StackStorm / st2web

StackStorm Web UI
http://www.stackstorm.com/features
Apache License 2.0
103 stars 82 forks source link

Creating a rule with the default criteria operator fails #897

Open winem opened 3 years ago

winem commented 3 years ago

I tried to create a rule that reacts on a specific slack message.

Selection_264

The criteria operator has not been changed and is still the one that's shown per default (regex).

Saving the rule fails with:

{ "faultstring": "For field: trigger.text, operator not in list of allowed operators: ['matchwildcard', 'matchregex', 'regex', 'iregex', 'eq', 'equals', 'neq', 'nequals', 'ieq', 'iequals', 'contains', 'icontains', 'ncontains', 'incontains', 'startswith', 'istartswith', 'endswith', 'iendswith', 'lt', 'lessthan', 'gt', 'greaterthan', 'td_lt', 'timediff_lt', 'td_gt', 'timediff_gt', 'exists', 'nexists', 'inside', 'in', 'ninside', 'nin', 'search']" }

This happens because the preselected operator is not sent to the backend as a look on the request parameters shows:

{
  "pack": "slack",
  "enabled": true,
  "trigger": {
    "type": "slack.message",
    "parameters": {}
  },
  "criteria": {
    "trigger.text": {
      "type": "",
      "pattern": "foo"
    }
  },
  "action": {
    "ref": "core.local",
    "parameters": {
      "cmd": "date -u"
    }
  },
  "name": "slack2",
  "description": "slack"
}

criteria.trigger.text.type should be regex.

It works fine if you select any other operator or any other operator and then regex again.

amanda11 commented 3 years ago

@winem - is this a new problem in 3.5? Would be good to confirm this is new to 3.5. If it's new to 3.5 then @m4dcoder i wonder if you know of any changes it's related to?

amanda11 commented 3 years ago

I do wonder if this has always been the case. Eg I recall if you create a rule and don't choose a pack then it fails to save - even though it shows a default pack of "default". You did always have to actually specify the value rather than the default.

If it's always been a problem then we should raise an issue, but it wouldn't be a blocker.

winem commented 3 years ago

I don't think that it's related to 3.5 and it wouldn't be a release blocker as the workaround is fairly easy.

I'll do some more tests on older releases tomorrow to see if any of the (potential) issues I saw so far is being introduced with 3.5 or an old one.