Hello!
I am trying to wrap my head around core.inject_trigger and having a really hard time to figure out it’s correct usage:
I am receiving a webhook from an external ticketing system and would like to emit a better formatted trigger back into the system.
The json is properly parsed and ran through the rule:
The commented echo works properly and the webhook content is shown. When using core.inject_trigger, the error I receive in the logs is:
2020-10-20 15:40:40,241 140700177833328 INFO enforcer [-] Invoking action core.inject_trigger for trigger_instance 5f8ee8d852364c03c0ca2c16 with params {"trigger": "itrp.xxx", "payload": "{{ trigger.body | tojson }}"}.
2020-10-20 15:40:40,274 140700177833328 ERROR enforcer [-] Failed kicking off execution for rule RuleDB(action=ActionExecutionSpecDB@140700175871568(ref="core.inject_trigger", parameters="{u'trigger': u'itrp.xxx', u'payload': u'{{ trigger.body | tojson }}'}"), context={}, criteria={}, description="Test QA ITRP", enabled=True, id=5f7f7a9052364ca2eae205bd, metadata_file="rules/ITRP-QA_Webhook.yaml", name="ITRP-
QA Webhook", pack="itrp", ref="itrp.ITRP-QA Webhook", tags=[], trigger="core.4fced566-b0d4-427a-ac10-8d88ae2011c8", type=RuleTypeSpecDB@140700175871696(ref="standard", parameters="{}"), uid="rule:itrp:ITRP-QA Webhook").
Traceback (most recent call last):
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/rules/enforcer.py", line 97, in enforce
execution_db = self._do_enforce()
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/rules/enforcer.py", line 148, in _do_enforce
additional_contexts=additional_contexts)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2reactor/rules/enforcer.py", line 204, in _invoke_action
liveaction_db, execution_db = action_service.create_request(liveaction_db)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/services/action.py", line 106, in create_request
allow_default_none=True)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/st2common/util/schema/__init__.py", line 304, in validate
jsonschema.validate(instance=instance, schema=schema, cls=cls, *args, **kwargs)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/jsonschema/validators.py", line 541, in validate
cls(schema, *args, **kwargs).validate(instance)
File "/opt/stackstorm/st2/local/lib/python2.7/site-packages/jsonschema/validators.py", line 130, in validate
raise error
ValidationError: u'{{ trigger.body | tojson }}' is not of type u'object', 'null'
Failed validating u'type' in schema['properties'][u'payload']:
{u'description': u'Trigger payload.', u'type': [u'object', 'null']}
I prepared the github repo to be installed with st2 pack install
https://github.com/cyberkov/st2-itrp
but one would need to update the webhook url in tests/simulate_itrp_webhook.sh
to try it.
When using payload: '{{ trigger.body }}'
it was failing as well, which led me to the
conversion to json.
Did I miss anything or am I just “holding it wrong”
Thanks a lot for your help!