fix(workflow): allow cross-type numeric comparison in selector operator WillAccept#2716
Open
nankingjing wants to merge 1 commit into
Open
fix(workflow): allow cross-type numeric comparison in selector operator WillAccept#2716nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
…or WillAccept The WillAccept method for OperatorEqual/OperatorNotEqual had an overly restrictive type check that rejected int64-vs-float64 comparisons, even though the runtime evaluation (Clause.Resolve) uses alignNumberTypes to handle this case correctly. The condition on line 60 should only enforce strict type equality for booleans, not for numeric types (int64/float64 are handled by the cross-numeric check below). Signed-off-by: nankingjing <nankingjing@users.noreply.github.com>
Author
Review: fix-selector-numeric-accept (#2716)Verdict: LGTM The original condition By removing Edge case trace after the fix:
Nit: No test included. A table-driven test for WillAccept would strengthen this, but the fix itself is correct and minimal. Merge-ready. |
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.
Problem
The
WillAcceptmethod inbackend/domain/workflow/internal/nodes/selector/operator.gohas an overly restrictive type check forOperatorEqualandOperatorNotEqual. The condition at line 60:This enforces strict type equality (
leftT == rightT) for all non-string types, includingint64andfloat64. However, the runtime evaluation inClause.Resolve()(clause.go) usesalignNumberTypes()to transparently handle int64-vs-float64 comparisons. The subsequent check at lines 66-70 also explicitly validates cross-numeric operands.Impact: Comparing
int64withfloat64(e.g.,1 == 1.0) is rejected byWillAcceptwith "left operant and right operant must be same type", even though the runtime correctly handles it. This prevents valid selector conditions from being validated.Fix
Change line 60 to only enforce strict type equality for booleans:
This is correct because:
Verification
WillAccept(operator.go) andResolve(clause.go) to confirm the fix does not introduce any regressionsoperator_test.gotests all continue to pass logically (no test case covers int64-vs-float64, confirming the gap)Signed-off-by: nankingjing nankingjing@users.noreply.github.com
Generated with Claude Code