Fix unbounded recursion in expression evaluation via circular reference detection#851
Merged
Haishi2016 merged 2 commits intoJul 23, 2026
Conversation
Activation inputs are exposed as triggers and are not evaluated unless a stage input references them, so the self-referencing value must live in the stage spec's inputs to exercise the circular dependency check.
Haishi2016
approved these changes
Jul 23, 2026
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 #850
Root cause
When the stage manager evaluates an activation's inputs, any stored value that looks like an expression is evaluated again (
readProperty/readPropertyInterfaceinapi/pkg/apis/v1alpha1/utils/parser.go): a value wrapped in${{...}}is fed back intoNewParser(v).Eval(evalCtx)with no cycle detection. A self-referencing input such asa: "${{$input(a)}}"(or mutual referencesa→b→a) recurses until the process runs out of stack — a fatal, unrecoverable error in Go that takes symphony-api down.Fix
Apply the same circular dependency guard that #433 introduced for
$configto the other expression sources. Every recursion cycle necessarily passes through one of the$property/$input/$output/$triggerfunction branches, so the check is placed at those four call sites:HasCircularDependency(object, key, context)rejects a key that is already on the current resolution path, with the same error shape as the catalog provider (BadConfig, "Detect circular dependency, object: %s, field: %s")UpdateDependencyList+DeepCopyDependencyListhelpers and carried down through the by-valueEvaluationContext, so sibling branches never see each other's pathNo changes to the coa module — the machinery from #433 is reused as-is.
Tests
parser_test.go: self-referencing input returns aBadConfigerror instead of recursing; mutually referencing inputs likewise; legitimate nested references without cycles still evaluate; a pre-seeded resolution path is rejected on first accessstage-manager_test.go: an activation with a self-referencing input fails the stage with the circular dependency error while the manager survives and processes subsequent activations normally