From 7962101e5e569cc47c2286dba4860f09762896f1 Mon Sep 17 00:00:00 2001 From: Novice <857526207@qq.com> Date: Tue, 5 Nov 2024 16:31:49 +0800 Subject: [PATCH] fix: iteration none output error (#10295) --- api/factories/variable_factory.py | 2 ++ api/tests/unit_tests/core/app/segments/test_factory.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/api/factories/variable_factory.py b/api/factories/variable_factory.py index d0c8c7e84f7da7..0191102b902cc9 100644 --- a/api/factories/variable_factory.py +++ b/api/factories/variable_factory.py @@ -91,6 +91,8 @@ def build_segment(value: Any, /) -> Segment: return ArrayObjectSegment(value=value) case SegmentType.FILE: return ArrayFileSegment(value=value) + case SegmentType.NONE: + return ArrayAnySegment(value=value) case _: raise ValueError(f"not supported value {value}") raise ValueError(f"not supported value {value}") diff --git a/api/tests/unit_tests/core/app/segments/test_factory.py b/api/tests/unit_tests/core/app/segments/test_factory.py index 72d277fad4bb8d..882a87239b84e4 100644 --- a/api/tests/unit_tests/core/app/segments/test_factory.py +++ b/api/tests/unit_tests/core/app/segments/test_factory.py @@ -13,6 +13,7 @@ StringVariable, ) from core.variables.exc import VariableError +from core.variables.segments import ArrayAnySegment from factories import variable_factory @@ -156,3 +157,9 @@ def test_variable_cannot_large_than_200_kb(): "value": "a" * 1024 * 201, } ) + + +def test_array_none_variable(): + var = variable_factory.build_segment([None, None, None, None]) + assert isinstance(var, ArrayAnySegment) + assert var.value == [None, None, None, None]