Describe the bug
When JSON fact is used, and when has some condition on a field which is missing in JSON, rule should consider that condition unmatched instead of erroring out entire execution.
If my condition is Event.Username == "john" || Event.Surname == "doe", if Event does not have Username field the execution fails with error like
got left hand expression error. got left hand expression error. got json field 'Username' is undefined" lib=grule-rule-engine package=ast
Instead here, it should consider Event.Username == "john" as false and evaluate Event.Surname == "doe" and match if it is true.
To Reproduce
Steps to reproduce the behavior:
I create code for this and that
rule Rule_90 "MatchingEquals1" salience 1 {
when
Event.Username == "john" || Event.Surname == "doe"
then
Output.Matched(Event.Surname, Event.Surname);
Retract("Rule_90");
Complete();
}
I see that
Error while evaluating rule Rule_90, got left hand expression error. got left hand expression error. got json field 'Username' is undefined" lib=grule-rule-engine package=ast time="2024-01-04T13:46:04+05:30
Expected behavior
Rule should match as next OR expression matches without error.
Additional context
It also fails if we are using missing field in then as well.
Describe the bug When JSON fact is used, and
when
has some condition on a field which is missing in JSON, rule should consider that condition unmatched instead of erroring out entire execution. If my condition isEvent.Username == "john" || Event.Surname == "doe"
, if Event does not have Username field the execution fails with error likegot left hand expression error. got left hand expression error. got json field 'Username' is undefined" lib=grule-rule-engine package=ast
Instead here, it should consider
Event.Username == "john"
as false and evaluateEvent.Surname == "doe"
and match if it is true.To Reproduce Steps to reproduce the behavior:
I create code for this and that
With a test for this and that
Instead of seeng this
Matching the rule
I see that
Error while evaluating rule Rule_90, got left hand expression error. got left hand expression error. got json field 'Username' is undefined" lib=grule-rule-engine package=ast time="2024-01-04T13:46:04+05:30
Expected behavior Rule should match as next OR expression matches without error.
Additional context It also fails if we are using missing field in then as well.