Open myllynen opened 1 year ago
would event.payload['vendor-product'].rule == "Test"
or event.payload['vendor-product']['rule'] == "Test"
work?
I tested that and it seems that using [
leads to ConditionParsingException
.
Perhaps the docs should be clarified first and then we could tweak our rulebooks accordingly. But in any case a quality implementation should not throw unexpected expectations for cases which are not completely unreasonable.
Hello. There are some constraints for event keys that are not properly documented yet. The way to deal with this kind of situation would be to use a source filter to transform the incoming events. For this specific case, we already provide a source filter that replaces dashes to underscores: https://github.com/ansible/event-driven-ansible/blob/main/extensions/eda/plugins/event_filters/dashes_to_underscores.py
Related with: https://issues.redhat.com/browse/AAP-11514
FWIW, we'll tweak the "pcp-pmie" JSON field name that triggered this issue to split it up into {"pcp":{"pmie":{ ... }}} - on discussing with @myllynen we think this will be a cleaner approach in general anyway.
Please confirm the following
Bug Summary
An unexpected exception is thrown when using a dash (minus) as part of the condition string:
condition: event.payload.vendor-product.rule == "Test"
Environment
Steps to reproduce
Trivial to reproduce:
Actual results
Unexcepted exception.
Expected results
No exception.
Additional information
While the code will likely be easy to fix I think the documentation should already at this point provide instruction how vendors should setup "namespace" for their products. I've now seen one project to use a generic condition name (
event.payload.<rule-name>
e.g.event.payload.lifecycle
) while another tried to create a namespace withevent.payload.project-component.rule
type approach.Since in most enterprises where only one port is expected for each service (such as EDA) instead of a separate port for each event source there needs to a way how to avoid overalapping names with different vendors and event sources. Perhaps we should a have separate doc issue for this.
Thanks.