StackStorm / StackStorm/st2

Regex in rule definition doesn't like escaped dots

Open
#4,702 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement logging status:not an issue
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

An escaped dot \. regex pattern within a rule definition throws an error when registering the pack.

ISSUE TYPE

Bug Report

STACKSTORM VERSION

Paste the output of st2 3.0.1, on Python 2.7.6:

OS / ENVIRONMENT / INSTALL METHOD

Ubuntu 14.04 Docker Container. The pack was both installed as python2 and using the python3 option.

STEPS TO REPRODUCE
  1. Create a new rules with the criterea
  trigger.action_ref:
    type: "regex"
    pattern: "[^(.*\.create_alert|.*\.process-failed-job|ostk_deploy\..*|ostk_auto_approve\..*)]"
  1. Register the pack
    st2 pack register [pack]
EXPECTED RESULTS

I expect the pack to register.

ACTUAL RESULTS
# st2 pack register ostk_common
ERROR: 400 Client Error: Bad Request
MESSAGE: Failed to register rule "/opt/stackstorm/packs.dev/ostk_common/rules/failed-job-monitor-v2.yaml" from pack "ostk_common": while scanning a double-quoted scalar
  in "/opt/stackstorm/packs.dev/ostk_common/rules/failed-job-monitor-v2.yaml", line 19, column 14
found unknown escape character '.'
  in "/opt/stackstorm/packs.dev/ostk_common/rules/failed-job-monitor-v2.yaml", line 19, column 21 for url: http://127.0.0.1:9101/v1/packs/register

Removing the escaped dot \. allows the pack to register.

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 the failing rules/failed-job-monitor-v2.yaml example and reproduce the error using st2 pack register [pack]. Trace the rule-registration path that parses the pattern, then verify that escaped dots are accepted and that registration succeeds without regressing other rule definitions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
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.