From b6dbb2f71eedc0066271834253b445b6f5c03f2d Mon Sep 17 00:00:00 2001 From: buua436 Date: Mon, 29 Jun 2026 10:51:57 +0800 Subject: [PATCH] fix: update variable completeness check to allow None parameter (#16389) --- agent/component/variable_assigner.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/agent/component/variable_assigner.py b/agent/component/variable_assigner.py index 5b5e39a825..163fa27727 100644 --- a/agent/component/variable_assigner.py +++ b/agent/component/variable_assigner.py @@ -40,6 +40,7 @@ class VariableAssignerParam(ComponentParamBase): class VariableAssigner(ComponentBase,ABC): component_name = "VariableAssigner" + _NO_PARAMETER_OPERATORS = {"clear", "remove_first", "remove_last"} @timeout(int(os.environ.get("COMPONENT_EXEC_TIMEOUT", 10*60))) def _invoke(self, **kwargs): @@ -47,11 +48,14 @@ class VariableAssigner(ComponentBase,ABC): return else: for item in self._param.variables: - if any([not item.get("variable"), not item.get("operator"), not item.get("parameter")]): + variable = item.get("variable") + operator = item.get("operator") + parameter = item.get("parameter") + + if any([not variable, not operator]): + raise ValueError("Variable is not complete.") + if operator not in self._NO_PARAMETER_OPERATORS and parameter is None: raise ValueError("Variable is not complete.") - variable=item["variable"] - operator=item["operator"] - parameter=item["parameter"] variable_value=self._canvas.get_variable_value(variable) new_variable=self._operate(variable_value,operator,parameter) self._canvas.set_variable_value(variable, new_variable)