fix: handle non-array segment types in Loop node (#24590)

Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com>
This commit is contained in:
-LAN-
2025-08-27 11:21:42 +08:00
committed by GitHub
parent a159c13333
commit 726c429772
2 changed files with 6 additions and 4 deletions

View File

@@ -572,5 +572,7 @@ class LLMGenerator:
error = str(e) error = str(e)
return {"error": f"Failed to generate code. Error: {error}"} return {"error": f"Failed to generate code. Error: {error}"}
except Exception as e: except Exception as e:
logger.exception("Failed to invoke LLM model, model: " + json.dumps(model_config.get("name")), exc_info=e) logger.exception(
"Failed to invoke LLM model, model: %s", json.dumps(model_config.get("name")), exc_info=True
)
return {"error": f"An unexpected error occurred: {str(e)}"} return {"error": f"An unexpected error occurred: {str(e)}"}

View File

@@ -524,7 +524,9 @@ class LoopNode(BaseNode):
@staticmethod @staticmethod
def _get_segment_for_constant(var_type: SegmentType, original_value: Any) -> Segment: def _get_segment_for_constant(var_type: SegmentType, original_value: Any) -> Segment:
"""Get the appropriate segment type for a constant value.""" """Get the appropriate segment type for a constant value."""
if var_type in [ if not var_type.is_array_type() or var_type == SegmentType.BOOLEAN:
value = original_value
elif var_type in [
SegmentType.ARRAY_NUMBER, SegmentType.ARRAY_NUMBER,
SegmentType.ARRAY_OBJECT, SegmentType.ARRAY_OBJECT,
SegmentType.ARRAY_STRING, SegmentType.ARRAY_STRING,
@@ -534,8 +536,6 @@ class LoopNode(BaseNode):
else: else:
logger.warning("unexpected value for LoopNode, value_type=%s, value=%s", original_value, var_type) logger.warning("unexpected value for LoopNode, value_type=%s, value=%s", original_value, var_type)
value = [] value = []
elif var_type == SegmentType.ARRAY_BOOLEAN:
value = original_value
else: else:
raise AssertionError("this statement should be unreachable.") raise AssertionError("this statement should be unreachable.")
try: try: