microsoft / microsoft/RulesEngine

On first condition met it shouldn't check other conditions

Open
#465 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
616
Avg merge
6m
Merged PRs (30d)
2

Description

First of all I apologies for my bad English.

We have following rule and in this when input1 is coming null we are getting following exception. But as we are checking input1 == null then it shouldn't check the conditions after that as it's returning true from there only.

Exception:
Exception while parsing expression input1 == null OR (input1 != null AND input1.legals != null AND input1.legals.Count() > 0) - No applicable method 'Count' exists in type 'Object'

Rule:
{
"RuleName": "LegalsNull",
"SuccessEvent": "Legals are OK.",
"ErrorMessage": "Legals should not be null.",
"ErrorType": "Error",
"RuleExpressionType": "LambdaExpression",
"Expression": "input1 == null OR (input1 != null AND input1.legals != null AND input1.legals.Count() > 0)"
}

I am already using
var reSettings = new ReSettings { NestedRuleExecutionMode = NestedRuleExecutionMode.Performance }; here.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported expression with input1 set to null and NestedRuleExecutionMode.Performance enabled. Trace the expression evaluation path responsible for calling Count on Object; done means the OR expression does not evaluate later conditions after input1 == null is true and the reported exception is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.