From cc21dc7f007ea753e2c2063922abac6122f7c8fc Mon Sep 17 00:00:00 2001 From: Ricardo-M-L <69202550+Ricardo-M-L@users.noreply.github.com> Date: Thu, 14 May 2026 12:33:17 +0800 Subject: [PATCH] fix: replace broken assert with raise ValueError in variable_assigner and loop (#13906) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit \`assert \"string\"\` always passes in Python because non-empty strings are truthy. This silently skips input validation: - **variable_assigner.py line 51**: \`assert \"Variable is not complete.\"\` → \`raise ValueError(\"Variable is not complete.\")\` - **loop.py line 59**: \`assert \"Loop Variable is not complete.\"\` → \`raise ValueError(\"Loop Variable is not complete.\")\` Without this fix, incomplete variables pass validation silently and cause a confusing KeyError on the next line. --- agent/component/loop.py | 2 +- agent/component/variable_assigner.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/component/loop.py b/agent/component/loop.py index 484dfae825..9558e1001e 100644 --- a/agent/component/loop.py +++ b/agent/component/loop.py @@ -56,7 +56,7 @@ class Loop(ComponentBase, ABC): for item in self._param.loop_variables: if any([not item.get("variable"), not item.get("input_mode"), not item.get("value"),not item.get("type")]): - assert "Loop Variable is not complete." + raise ValueError("Loop Variable is not complete.") if item["input_mode"]=="variable": self.set_output(item["variable"],self._canvas.get_variable_value(item["value"])) elif item["input_mode"]=="constant": diff --git a/agent/component/variable_assigner.py b/agent/component/variable_assigner.py index dd6182c7ce..0f78213684 100644 --- a/agent/component/variable_assigner.py +++ b/agent/component/variable_assigner.py @@ -48,7 +48,7 @@ class VariableAssigner(ComponentBase,ABC): else: for item in self._param.variables: if any([not item.get("variable"), not item.get("operator"), not item.get("parameter")]): - assert "Variable is not complete." + raise ValueError("Variable is not complete.") variable=item["variable"] operator=item["operator"] parameter=item["parameter"]