Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(tools): normalize legacy comma-separated multiple-select values (#45058)
Taranum Wasub8cc68d8cc0d
diff --git a/api/core/tools/entities/tool_entities.py b/api/core/tools/entities/tool_entities.pyindex 5be418cdac9..d6ae0491241 100644--- a/api/core/tools/entities/tool_entities.py+++ b/api/core/tools/entities/tool_entities.py@@ -401,6 +401,10 @@ class ToolParameter(PluginParameter):parameter_value = self.default if value is None else valueif parameter_value is None:parameter_value = []+ if isinstance(parameter_value, str):+ # Historical workflows and older frontends stored a multiple-select+ # value as a comma-separated string; normalize it before the checks.+ parameter_value = [item.strip() for item in parameter_value.split(",") if item.strip()]if not isinstance(parameter_value, list):raise ValueError(f"tool parameter {self.name} must be a list when multiple is true")if not all(isinstance(item, str) for item in parameter_value):diff --git a/api/tests/unit_tests/core/tools/__base/test_tool.py b/api/tests/unit_tests/core/tools/__base/test_tool.pyindex 1de3780c63a..d32f62bae82 100644--- a/api/tests/unit_tests/core/tools/__base/test_tool.py+++ b/api/tests/unit_tests/core/tools/__base/test_tool.py@@ -148,8 +148,12 @@ def test_invoke_preserves_multiple_select_values(sqlite_session: Session):assert tool.last_invocation is not Noneassert tool.last_invocation["tool_parameters"] == {"choice": ["a", "b"]}+ # A legacy comma-separated string is normalized, not rejected (#45003).+ list(tool.invoke(session=sqlite_session, user_id="user-1", tool_parameters={"choice": "a,b"}))+ assert tool.last_invocation["tool_parameters"] == {"choice": ["a", "b"]}+ # A non-list, non-string value is still rejected.with pytest.raises(ValueError, match="must be a list"):- tool.invoke(session=sqlite_session, user_id="user-1", tool_parameters={"choice": "a"})+ tool.invoke(session=sqlite_session, user_id="user-1", tool_parameters={"choice": 1})def test_invoke_supports_list_and_generator_results(sqlite_session: Session):diff --git a/api/tests/unit_tests/core/tools/entities/test_tool_entities.py b/api/tests/unit_tests/core/tools/entities/test_tool_entities.pyindex cd38809c7d3..a289e7da99b 100644--- a/api/tests/unit_tests/core/tools/entities/test_tool_entities.py+++ b/api/tests/unit_tests/core/tools/entities/test_tool_entities.py@@ -52,7 +52,6 @@ def test_tool_parameter_accepts_multiple_select_declarations(parameter_type: Too@pytest.mark.parametrize(("value", "message"),[- ("a", "must be a list"),(["a", 1], "only strings"),(["missing"], "not in options"),([], "not found in tool config"),@@ -65,6 +64,28 @@ def test_multiple_select_normalization_rejects_invalid_values(value: object, mesparameter.init_frontend_parameter(value)+def test_multiple_select_normalization_splits_legacy_comma_separated_string():+ # Historical workflows and older frontends stored a multiple-select value+ # as a comma-separated string; it must normalize to a list, not raise.+ parameter = _make_select_parameter(multiple=True, required=False)++ assert parameter.init_frontend_parameter("a,b") == ["a", "b"]+ assert parameter.init_frontend_parameter(" a , b ") == ["a", "b"]+ assert parameter.init_frontend_parameter("") == []+++def test_multiple_select_normalization_keeps_required_and_option_checks_for_strings():+ # The string-to-list normalization must not weaken the existing checks:+ # a required parameter stays required, and SELECT options still apply.+ parameter = _make_select_parameter(multiple=True, required=True)++ for empty in ("", " , , "):+ with pytest.raises(ValueError, match="not found in tool config"):+ parameter.init_frontend_parameter(empty)+ with pytest.raises(ValueError, match="not in options"):+ parameter.init_frontend_parameter("a,invalid")++def test_multiple_select_normalization_preserves_explicit_empty_list():parameter = _make_select_parameter(multiple=True, default=["a"])