mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 09:28:04 +08:00
feat: handle none value in mcp tool node
This commit is contained in:
@ -149,10 +149,30 @@ def cast_parameter_value(typ: enum.StrEnum, value: Any, /):
|
||||
return value
|
||||
case PluginParameterType.ARRAY:
|
||||
if not isinstance(value, list):
|
||||
# Try to parse JSON string for arrays
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
import json
|
||||
|
||||
parsed_value = json.loads(value)
|
||||
if isinstance(parsed_value, list):
|
||||
return parsed_value
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
pass
|
||||
return [value]
|
||||
return value
|
||||
case PluginParameterType.OBJECT:
|
||||
if not isinstance(value, dict):
|
||||
# Try to parse JSON string for objects
|
||||
if isinstance(value, str):
|
||||
try:
|
||||
import json
|
||||
|
||||
parsed_value = json.loads(value)
|
||||
if isinstance(parsed_value, dict):
|
||||
return parsed_value
|
||||
except (json.JSONDecodeError, ValueError):
|
||||
pass
|
||||
return {}
|
||||
return value
|
||||
case _:
|
||||
|
||||
Reference in New Issue
Block a user