microsoft / microsoft/RulesEngine

Action Workflow and global params do not work together

Open
#626 2 comments 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

STR

Let's say you have this action workflow:

{
  "$schema": "https://raw.githubusercontent.com/microsoft/RulesEngine/main/schema/workflow-schema.json",
  "WorkflowName": "MailEvaluationWorkflow",
  "GlobalParams": [
    {
      "Name": "myFavouriteThing",
      "Expression": "1"
    }
  ],
  // some action workflow rules here
What happens

This will always fail, if you have at least two rules, with an exception like this:

Exception: Error while executing rule : SecondRuleName - An item with the same key has already been added. Key: myFavouriteThing, ActionResult.Output: null

What should happen

IMHO this makes GlobalParams absolutely useless, as you cannot use them. It should just inject them once

In 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.3

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

Reproduce the failure with an action workflow containing GlobalParams and at least two rules, using the issue's example and RulesEngine v5.0.3. Trace the action-workflow handling of global parameters, then add a regression test showing that the parameter is injected once and remains available to each rule without duplicate-key errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.