StackStorm / st2

StackStorm (aka "IFTTT for Ops") is event-driven automation for auto-remediation, incident responses, troubleshooting, deployments, and more for DevOps and SREs. Includes rules engine, workflow, 160 integration packs with 6000+ actions (see https://exchange.stackstorm.org) and ChatOps. Installer at https://docs.stackstorm.com/install/index.html
https://stackstorm.com/
Apache License 2.0
6.07k stars 749 forks source link

Searching for a string with `:` in it in YAQL does not work #3345

Closed lakshmi-kannan closed 7 years ago

lakshmi-kannan commented 7 years ago

For example, this snippet:

- found: <% "FAIL: something" in $.echo_output %>
- notfound: <% not "FAIL: something" in $.echo_output %>

complains mapping values are not allowed here.

Escaping the : does not work as in both these variables evaluate to True.

- found: <% "FAIL:\ something" in $.echo_output %>
- notfound: <% not "FAIL:\ something" in $.echo_output %>

when

"echo_output": "FAIL: something"

Regex works according to john.welborn on slack

- found: <% regex('.*FAIL:\ something.*').search($.echo_output) %>
m4dcoder commented 7 years ago

The colon is being interpreted by YAML safe load as part of the YAML text. If you put a double quote around the YAQL expression, YAML will load this correctly. The correction is posted below.

- found: "<% 'FAIL: something' in $.echo_output %>"
- notfound: "<% not 'FAIL: something' in $.echo_output %>"

If this problem persists for you, please reopen this issue.

estee-tew commented 7 years ago

https://stackstorm.slack.com/archives/community/p1491853765137460