From f377971da44b09d1f9ed6d509e03eafccf5f1404 Mon Sep 17 00:00:00 2001 From: Madhu Kanoor Date: Tue, 14 Feb 2023 17:00:51 -0500 Subject: [PATCH] Allow for empty payloads If the payload is empty then skip over it, in some special cases the ruleset might not need any direct events but would be using set_facts to generate the data. This came about in PR https://github.com/ansible/ansible-rulebook/pull/349 Where there is no payload. This leads to an error in the source ``` 2023-02-14 16:38:53,582 - ansible_rulebook.engine - ERROR - Source error Traceback (most recent call last): File "/Users/madhukanoor/devsrc/ansible-rulebook/ansible_rulebook/engine.py", line 154, in start_source await entrypoint(fqueue, args) File "/Users/madhukanoor/devsrc/ansible-rulebook/tests/e2e/../sources/generic.py", line 97, in main data.update(event) ``` --- tests/sources/generic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/sources/generic.py b/tests/sources/generic.py index 0c6aa2eb..aae34522 100644 --- a/tests/sources/generic.py +++ b/tests/sources/generic.py @@ -81,6 +81,8 @@ async def main(queue: asyncio.Queue, args: Dict[str, Any]): if randomize: random.shuffle(payload) for event in payload: + if not event: + continue for _ in range(repeat_count): data = {} if create_index: