mirror of
https://github.com/langgenius/dify.git
synced 2026-06-26 06:41:10 +08:00
Merge eccf0edbba into bb921bcc45
This commit is contained in:
commit
3a4d9346b5
@ -45,6 +45,8 @@ class BasicVariablesConfigManager:
|
||||
|
||||
# variables and external_data_tools
|
||||
for variables in config.get("user_input_form", []):
|
||||
if not variables:
|
||||
continue
|
||||
variable_type = list(variables.keys())[0]
|
||||
if variable_type == VariableEntityType.EXTERNAL_DATA_TOOL:
|
||||
variable = variables[variable_type]
|
||||
@ -112,6 +114,8 @@ class BasicVariablesConfigManager:
|
||||
|
||||
variables = []
|
||||
for item in config["user_input_form"]:
|
||||
if not item:
|
||||
raise ValueError("Each item in user_input_form must be a non-empty object")
|
||||
key = list(item.keys())[0]
|
||||
# if key not in {"text-input", "select", "paragraph", "number", "external_data_tool"}:
|
||||
if key not in {
|
||||
|
||||
@ -70,6 +70,14 @@ class TestBasicVariablesConfigManagerConvert:
|
||||
assert len(variables) == 2
|
||||
assert len(external) == 1
|
||||
|
||||
def test_convert_empty_form_item_skipped(self):
|
||||
config = {"user_input_form": [{}]}
|
||||
|
||||
variables, external = BasicVariablesConfigManager.convert(config)
|
||||
|
||||
assert variables == []
|
||||
assert external == []
|
||||
|
||||
def test_convert_external_data_tool_without_config_skipped(self):
|
||||
config = {
|
||||
"user_input_form": [
|
||||
@ -109,6 +117,12 @@ class TestValidateVariablesAndSetDefaults:
|
||||
with pytest.raises(ValueError):
|
||||
BasicVariablesConfigManager.validate_variables_and_set_defaults(config)
|
||||
|
||||
def test_validate_empty_form_item_raises(self):
|
||||
config = {"user_input_form": [{}]}
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
BasicVariablesConfigManager.validate_variables_and_set_defaults(config)
|
||||
|
||||
def test_validate_missing_label_raises(self):
|
||||
config = {"user_input_form": [{VariableEntityType.TEXT_INPUT: {"variable": "name"}}]}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user