Skip to content

armgit / dify

Public Imported from GitHub
0

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.

Fix UpdatedVariable truncation crash (#27359)

-LAN-8ff6de91b0ae
diff --git a/api/services/variable_truncator.py b/api/services/variable_truncator.py
index 4e13d2d9642..6f8adb75367 100644
--- a/api/services/variable_truncator.py
+++ b/api/services/variable_truncator.py
@@ -283,7 +283,7 @@ class VariableTruncator:
break
remaining_budget = target_size - used_size
- if item is None or isinstance(item, (str, list, dict, bool, int, float)):
+ if item is None or isinstance(item, (str, list, dict, bool, int, float, UpdatedVariable)):
part_result = self._truncate_json_primitives(item, remaining_budget)
else:
raise UnknownTypeError(f"got unknown type {type(item)} in array truncation")
@@ -373,6 +373,11 @@ class VariableTruncator:
return _PartResult(truncated_obj, used_size, truncated)
+ @overload
+ def _truncate_json_primitives(
+ self, val: UpdatedVariable, target_size: int
+ ) -> _PartResult[Mapping[str, object]]: ...
+
@overload
def _truncate_json_primitives(self, val: str, target_size: int) -> _PartResult[str]: ...