diff --git a/api/__pycache__/settings.cpython-313.pyc b/api/__pycache__/settings.cpython-313.pyc index 6c4febb9..18384023 100644 Binary files a/api/__pycache__/settings.cpython-313.pyc and b/api/__pycache__/settings.cpython-313.pyc differ diff --git a/app/__pycache__/models.cpython-313.pyc b/app/__pycache__/models.cpython-313.pyc index 25aea580..e15b329c 100644 Binary files a/app/__pycache__/models.cpython-313.pyc and b/app/__pycache__/models.cpython-313.pyc differ diff --git a/app/__pycache__/workflow_utils.cpython-313.pyc b/app/__pycache__/workflow_utils.cpython-313.pyc index 14eea1e2..0f4ac96b 100644 Binary files a/app/__pycache__/workflow_utils.cpython-313.pyc and b/app/__pycache__/workflow_utils.cpython-313.pyc differ diff --git a/app/workflow_utils.py b/app/workflow_utils.py index fa66c7ed..54424e5e 100644 --- a/app/workflow_utils.py +++ b/app/workflow_utils.py @@ -54,6 +54,37 @@ def resolve_value(expr, context): except (ValueError, TypeError): print(f" [ERROR] Math function {func_name} failed with values: {arg1_val}, {arg2_val}") return 0 + + # ============================================= + # 2.1. Hàm xử lý list: $append(list, element) + # ============================================= + append_match = re.match(r"^\$append\(([^,]+),\s*(.+)\)$", expr, re.DOTALL) + if append_match: + list_expr = append_match.group(1).strip() + element_expr = append_match.group(2).strip() + + # 1. Resolve the list + target_list = resolve_value(list_expr, context) + if target_list is None: + target_list = [] + + # Ensure it's a copy so we don't modify the original context variable directly + target_list = list(target_list) + + # 2. Resolve the element + resolved_element = resolve_value(element_expr, context) + + if isinstance(resolved_element, str): + try: + import json + element_to_append = json.loads(resolved_element) + except json.JSONDecodeError: + element_to_append = resolved_element + else: + element_to_append = resolved_element + + target_list.append(element_to_append) + return target_list # ============================================= # 3. Helper: Lấy giá trị từ context theo đường dẫn dotted