fix: use FloatVariable for number-type variables with integer values#36354
Open
EvanYao826 wants to merge 1 commit into
Open
fix: use FloatVariable for number-type variables with integer values#36354EvanYao826 wants to merge 1 commit into
EvanYao826 wants to merge 1 commit into
Conversation
When value_type is 'number' and the value is an integer (e.g. 0), the code was creating IntegerVariable and changing value_type to 'integer'. This caused subsequent turns to fail with 'not supported value type integer' when a code node outputs a float value for the same variable. Fix: when value_type is 'number', always create FloatVariable (converting int values to float) so the variable type stays consistent across turns. Fixes langgenius#36346
Contributor
Pyrefly Type Coverage
|
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
When
value_typeis"number"and the value is an integer (e.g.0), the_build_variable_from_mappingfunction creates anIntegerVariableand changesvalue_typeto"integer". This causes subsequent conversation turns to fail with:when a code node outputs a float value for the same conversation variable.
Steps to Reproduce
value: 0.0(stored asvalue: 0,value_type: number)numbertointegerFix
When
value_typeis"number"and the value is an integer, always create aFloatVariable(converting the int value to float). This ensures the variable type stays asfloatacross conversation turns, which is compatible with both integer and float values from code nodes.Also added
not isinstance(value, bool)guard sinceboolis a subclass ofintin Python.Fixes #36346