Repository navigation
Fix EvaluateRule action failing when the target workflow has GlobalParams (#626) - #760
Open
Martin Brekhof (MBrekhof) wants to merge 1 commit into
Open
Martin Brekhof (MBrekhof) wants to merge 1 commit into
Martin Brekhof (MBrekhof) wants to merge 1 commit into
Conversation
…rams (microsoft#626) The inputs an EvaluateRule action forwards come from RuleResultTree.Inputs, which already holds the source rule's evaluated GlobalParams. The target workflow then evaluates its own GlobalParams again, so chaining into any workflow with globals failed with "The identifier 'x' was defined more than once" (or a GlobalParam/input collision error). EvaluateRuleAction now drops forwarded params named like the target workflow's GlobalParams before the call; the target recomputes them from the remaining inputs. Names are compared the way the expression parser compares identifiers (IsExpressionCaseSensitive), nothing is dropped when EnableScopedParams is off, and additionalInputs are added after the drop so they behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #626.
Problem
An
EvaluateRuleaction that chains into a workflow withGlobalParamsalways fails. The action forwards the source rule'sRuleResultTree.Inputs, which already contain the evaluated global params. The target workflow then evaluates its ownGlobalParamsagain, so the same name is defined twice:With the default
EnableExceptionAsErrorMessage = true, nothing is thrown, butActionRuleResult.Exceptioncarries a GlobalParam/input collision error andOutputisnull. The existing workaround was"inputFilter": [], which also drops every real input.Repro: workflow
wfwithGlobalParams: [{ g = input1.X }], ruler2withOnSuccess: EvaluateRule { workflowName: wf, ruleName: r1 }, thenExecuteActionWorkflowAsync("wf", "r2", input1).Solution
EvaluateRuleAction.Runnow drops forwarded params named like the target workflow'sGlobalParamsbefore chaining (afterinputFilter, beforeadditionalInputs). The target workflow recomputes them from the remaining inputs.ReSettings.IsExpressionCaseSensitiveis set.EnableScopedParamsisfalse, because globals are not evaluated then.additionalInputsare added after the drop and are still evaluated against the full source inputs, so they can reference source globals.ExecuteActionWorkflowAsyncare unchanged. A caller input that collides with a global still raises the existing collision error.RulesCache.GetGlobalParamNames), not viaGetWorkflow, which resolvesWorkflowsToInject.RegisterRuleonly compiles the top-level workflow's globals.internal.Tests
test/RulesEngine.UnitTest/Issue626Test.cs:ExecuteActionWorkflowAsync(with and withoutEnableExceptionAsErrorMessage) and throughExecuteAllRulesAsyncGis replaced by the target's recomputedg(case-insensitive default)IsExpressionCaseSensitive = true,Gandgboth stay availableadditionalInputswork together with globalsEnableScopedParams = falseleaves an input named like a global untouchedFive of these fail on
main. The other three guard against dropping too much. The full suite passes on net8.0, net9.0 and net10.0.🤖 Generated with Claude Code