Skip to content

Commit

Permalink
Allow for empty payloads
Browse files Browse the repository at this point in the history
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 #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)
```
  • Loading branch information
mkanoor committed Feb 14, 2023
1 parent 3f9793c commit f377971
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/sources/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit f377971

Please sign in to comment.