You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that event-driven-ansible collection is open source software provided for free and that I might not receive a timely response.
Bug Summary
When trying to check if a 'Token' header is set for a webhook event, ... is not defined is not triggering. If I change to ... is defined the behavior works as expected.
1.1.0
Executable location = /home/dustin/projects/eda/.venv/bin/ansible-rulebook
Drools_jpy version = 0.3.9
Java home = /usr/lib/jvm/java-17-openjdk-amd64
Java version = 17.0.12
Python version = 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
Steps to reproduce
Install ansible, ansible-rulebook, and dependencies.
Create the test.yml rulebook
Run the rule book
Use curl to send sample data to the webhook listener
Actual results
The expected rule does not trigger, one of the latter rules triggers.
Expected results
When sending a request with no Token header set, the first rule should trigger.
Additional information
Rulebook:
# This
---
- name: Webhook for testinghosts: localhostsources:
- name: WEBHOOK TESTansible.eda.webhook:
host: 0.0.0.0port: 8100rules:
- name: No Tokencondition: event.meta.headers.Token is not definedactions:
- debug:
msg: "No Token Provided\n{{ event.meta.headers.Token is not defined }}\n{{ event.meta.headers }}"
- name: Incorrect Tokencondition: event.meta.headers.Token != 'ThisIsMyToken'actions:
- debug:
msg: "Wrong Token Provided"
- name: Incorrect Payloadcondition: event.meta.headers != "Hello Testing World"actions:
- debug:
msg: "Unexpected payload"
Test Commands and the resulting events using --verbose and --print-events are below. As you can see, the first command attempts to trigger the first rule. However, the third rule is triggered instead.
Command 1:
# No Token wrong payload
curl -H 'Content-Type: application/json' -d "{\"message\": \"Ansible is super cool\"}" 127.0.0.1:8100/endpoint
Result 1:
2024-09-04 12:44:16.346942 [received event] *******************************************************************************************************************************************
Ruleset: Webhook for testing
Event:
{'meta': {'endpoint': 'endpoint',
'headers': {'Accept': '*/*',
'Content-Length': '36',
'Content-Type': 'application/json',
'Host': '127.0.0.1:8100',
'User-Agent': 'curl/7.81.0'},
'received_at': '2024-09-04T16:44:16.346549Z',
'source': {'name': 'WEBHOOK TEST', 'type': 'ansible.eda.webhook'},
'uuid': '126567d8-58c5-40bb-aff8-c1fdb17acc3e'},
'payload': {'message': 'Ansible is super cool'}}
******************************************************************************************************************************************************************************************
2024-09-04 12:44:16 348 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.MemoryMonitorUtil - Memory occupation threshold set to 90%
2024-09-04 12:44:16 348 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.MemoryMonitorUtil - Memory check event count threshold set to 64
2024-09-04 12:44:16 348 [main] INFO org.drools.ansible.rulebook.integration.api.rulesengine.MemoryMonitorUtil - Exit above memory occupation threshold set to false** 2024-09-04 12:44:16.359004 [debug] ****************************************************************************************************************************************************
Unexpected payload
******************************************************************************************************************************************************************************************
@DustinWi The "is not defined" is tricky to use since it can lead to a lot of triggering of rules, when the payload doesn't have the required keys. In ansible-rulebook if a "key" is missing the rule is skipped, it doesn't raise an exception and stop. So what is your use case? Are you trying to guard against the key missing?
Please confirm the following
Bug Summary
When trying to check if a 'Token' header is set for a webhook event,
... is not defined
is not triggering. If I change to... is defined
the behavior works as expected.Environment
OS:
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=22.04 DISTRIB_CODENAME=jammy DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
Python:
Ansible-Rulebook:
Steps to reproduce
Actual results
The expected rule does not trigger, one of the latter rules triggers.
Expected results
When sending a request with no Token header set, the first rule should trigger.
Additional information
Rulebook:
Test Commands and the resulting events using
--verbose
and--print-events
are below. As you can see, the first command attempts to trigger the first rule. However, the third rule is triggered instead.Command 1:
Result 1:
Command 2:
Result 2:
Command 3:
Result 3:
Command 4:
Result 4:
Command 5:
Result 5:
The text was updated successfully, but these errors were encountered: