fix: 修复工作流函数节点输入参数类型未校验错误

This commit is contained in:
zhangshaohu 2024-08-27 22:48:32 +08:00 committed by shaohuzhang1
parent e6045f439e
commit a53c6829c7
2 changed files with 26 additions and 20 deletions

View File

@ -44,16 +44,19 @@ def get_field_value(debug_field_list, name, is_required):
def valid_reference_value(_type, value, name):
if _type == 'int':
return isinstance(value, int)
if _type == 'float':
return isinstance(value, float)
if _type == 'dict':
return isinstance(value, dict)
if _type == 'array':
return isinstance(value, list)
if _type == 'string':
return isinstance(value, str)
raise Exception(500, f'字段:{name}类型:{_type}值:{value}类型错误')
instance_type = int
elif _type == 'float':
instance_type = float
elif _type == 'dict':
instance_type = dict
elif _type == 'array':
instance_type = list
elif _type == 'string':
instance_type = str
else:
raise Exception(500, f'字段:{name}类型:{_type} 不支持的类型')
if not isinstance(value, instance_type):
raise Exception(f'字段:{name}类型:{_type}值:{value}类型错误')
def convert_value(name: str, value, _type, is_required, source, node):

View File

@ -33,16 +33,19 @@ def write_context(step_variable: Dict, global_variable: Dict, node, workflow):
def valid_reference_value(_type, value, name):
if _type == 'int':
return isinstance(value, int)
if _type == 'float':
return isinstance(value, float)
if _type == 'dict':
return isinstance(value, dict)
if _type == 'array':
return isinstance(value, list)
if _type == 'string':
return isinstance(value, str)
raise Exception(500, f'字段:{name}类型:{_type}值:{value}类型错误')
instance_type = int
elif _type == 'float':
instance_type = float
elif _type == 'dict':
instance_type = dict
elif _type == 'array':
instance_type = list
elif _type == 'string':
instance_type = str
else:
raise Exception(500, f'字段:{name}类型:{_type} 不支持的类型')
if not isinstance(value, instance_type):
raise Exception(f'字段:{name}类型:{_type}值:{value}类型错误')
def convert_value(name: str, value, _type, is_required, source, node):