Throw a better exception if we fail to templatize trigger payload in the rule enforcer #1492
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, a known limitation is that trigger payload which is matched against in the rules engine can't contain special Jinja2 characters such as "{{", unless you are referencing variable in a datastore inside the payload.
For example, the following would fail:
(we try to reference attribute "bar" of variable "foo" which is not defined / available inside the template context)
If the payload contains those special characters, they need to be explicitly escaped inside the payload before sending trigger into the system.
Before this change, a really cryptic exception was thrown which made it hard to figure out the root cause. This pull request doesn't solve the root cause (we need to decide how to handle that), but it at least saves user some time debugging what went wrong.
Explicit escaping is obviously not ideal (especially since in a lot of cases, users just want to directly pipe data from 3rd party systems into StackStorm and they don't want to add another step which processes / sanitizes this data), but as long as we support key-value looks in the trigger payload, I can't think of any good solution for that.
Suggestions welcome.