fix: [AAP-50916] fix rulebook activation idempotence#463
Merged
Conversation
This fixes a bug where rulebook activations with event streams were
considered different even though the parameters of the tasks were the
same. The cause was a difference between the information returned from
the backend and the return from yaml.dump() when parsing the event
streams from the task parameter. The yaml.dump() adds a trailing
newline at the end of the dumped YAML string, which is the default
behavior. E.g:
info from the eda-server:
```
'source_mappings': '- event_stream_id: 12\\n event_stream_name: Test_EventStream_c99484c1-45a1-5c5f-a067-877f4e002f9c\\n rulebook_hash: 1e0f22025ab0a4e729fb68bcb9497412c3d9f477ce5a8cb91cc2ef15e35c4dc6\\n source_name: __SOURCE_1'
```
return from parsing the task's event streams parameter with
yaml.dump():
```
'source_mappings': '- event_stream_id: 12\\n event_stream_name: Test_EventStream_c99484c1-45a1-5c5f-a067-877f4e002f9c\\n rulebook_hash: 1e0f22025ab0a4e729fb68bcb9497412c3d9f477ce5a8cb91cc2ef15e35c4dc6\\n source_name: __SOURCE_1\\n'
```
This causes the module to consider the objects as different, and then
calling the update() function incorrectly.
To prevent this, now we simply add a rstrip("\n") to the yaml.dump()
call, which removes the trailing newline from the dumped string,
allowing the module to correctly compare the two objects and detect
that no changes were made, thus preserving idempotence.
A test was also added to make sure the behavior is expected for
activations with event streams.
3 tasks
Alex-Izquierdo
approved these changes
Aug 11, 2025
Contributor
|
good catch! |
ttuffin
approved these changes
Aug 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://issues.redhat.com/browse/AAP-50916
This fixes a bug where rulebook activations with event streams were considered different even though the parameters of the tasks were the same. The cause was a difference between the information returned from the backend and the return from
yaml.dump()when parsing the event streams from the task parameter. Theyaml.dump()adds a trailing newline at the end of the dumped YAML string, which is the default behavior. E.g:info from the eda-server:
return from parsing the task's event streams parameter with
yaml.dump():This causes the module to consider the objects as different, and then call the
update()function incorrectly.To prevent this, now we simply add a
rstrip("\n")to theyaml.dump()call, which removes the trailing newline from the dumped string, allowing the module to correctly compare the two objects and detect that no changes were made, thus preserving idempotence.A test was also added to ensure the expected behavior from activations with event streams.