Skip to content

If an execution took an exception in the next runs error message is transfered even if it successes. #590

Description

If a workflow took an exception in . In the next run error message is transfered even if It successes. Sample code is stated below.

public class HasException
{
    internal class TestClass
    {
        private int counter = 0;
        private string simpleProp;

        public string SimpleProp {
            get {
                if (counter++ == 0)
                {
                    throw new ArgumentException("Canım istedi");
                }
                return simpleProp;
            }
            set {
                simpleProp = value;
            }
        }
    }

    public void Run()
    {
        Console.WriteLine($"Running {nameof(NestedInputDemo)}....");

        TestClass instance = new();
        instance.SimpleProp = "simpleProp";

        Workflow workflow = new();
        workflow.WorkflowName = "NestedInputDemoWorkflow1";
        workflow.Rules = new List<Rule>() {
            new Rule() {
                RuleName = "CheckNestedSimpleProp",
                RuleExpressionType = RuleExpressionType.LambdaExpression,
                Expression = "SimpleProp == \"simpleProp\"",
                ErrorMessage = "One or more adjust rules failed."
            }
        };

        var settings = new ReSettings();
        settings.UseFastExpressionCompiler = false;
        var bre = new RulesEngine.RulesEngine(new Workflow[] { workflow }, settings);
        var resultList = bre.ExecuteAllRulesAsync(workflow.WorkflowName, instance).Result;
        resultList.OnSuccess((eventName) => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}. {resultList[0].ExceptionMessage}");
        }).OnFail(() => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure. {resultList[0].ExceptionMessage}");
        });
        resultList = bre.ExecuteAllRulesAsync(workflow.WorkflowName, instance).Result;
        resultList.OnSuccess((eventName) => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}");
        }).OnFail(() => {
            Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure");
        });
    }
}

Activity

  1. taskinozdemir commented on Mar 5, 2024

    @taskinozdemir
    ContributorAuthor

    I have created a pr for fixing this issue #592. Also I added a unit test to simulate the problem. Can you help us. This is a critical issue.

  2. asulwer commented on Jun 27, 2024

    @asulwer

    this project is no longer maintained but...my fork is. i will look into your code and merge into my fork

  3. added 2 commits that reference this issue on Jun 27, 2024
  4. asulwer commented on Jun 27, 2024

    @asulwer

    your PR has been merged with my fork, manually

  5. added 2 commits that reference this issue on May 27, 2026
  6. YogeshPraj commented on May 29, 2026

    @YogeshPraj
    Contributor

    Previously fixed in #592; regression coverage added in PR #729: #729

    Added Issue590Test.cs to verify exception messages do not persist across subsequent executions.

    Verified in preview package RulesEngine 6.0.1-preview.1:
    dotnet add package RulesEngine --version 6.0.1-preview.1 --prerelease

    Closing as already fixed and covered by regression tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions