Closed rklec closed 2 months ago
@rklec please review the code below to see how it compares to the error you are experiencing. i created this workflow with two action rules. first one fails, second one is successful.
var workflows = new Workflow[] {
new() {
WorkflowName = "Test Workflow3",
GlobalParams = new List<ScopedParam> {
new ScopedParam {
Name = "GPExpress",
Expression = "1"
}
},
Rules = new List<Rule> {
new() {
RuleName = "Test Rule 1",
Expression = "GPExpress < 0",
Actions = new RuleActions {
OnSuccess = new ActionInfo {
Name = "OutputExpression",
Context = new Dictionary<string, object> {{"expression", "GPExpress"}}
}
}
},
new() {
RuleName = "Test Rule 2",
Expression = "GPExpress >= 0",
Actions = new RuleActions {
OnSuccess = new ActionInfo {
Name = "OutputExpression",
Context = new Dictionary<string, object> {{"expression", "GPExpress"}}
}
}
}
}
}
};
@rklec have you had a chance to review the code that i posted?
STR
Let's say you have this action workflow:
What happens
This will always fail, if you have at least two rules, with an exception like this:
What should happen
IMHO this makes
GlobalParams
absolutely useless, as you cannot use them. It should just inject them onceIn a basic workflow this works fine, so this only affects the action workflow.
More information
I have found https://github.com/microsoft/RulesEngine/issues/259, which seems to be about the same issue(?), where filtering etc. was introduced. However, IMHO, this is still not a good way to handle it, is it?
Because come on, what use case does
GlobalParams
even have then? You cannot use them in any way if you have two rules, unless you do some filtering, which really is kinda silly to then always filter, is it?Workaround
Apparently just define all global params as "local params" in your first rule, which is passed to all others unless you filter. This kinda makes them "global" IMHO and is not a good naming and for me at least was totally confusing. And I had to read and understand the issue here first to get why this happens.
System
RulesEngine
v5.0.3Copied from https://github.com/microsoft/RulesEngine/issues/626 as I highly suspect it affects this fork as well.