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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
feat(api/core/app/segments/parser.py): Remove blank segment in `convert_template` (#6709)
-LAN-5d77dc4f5820
diff --git a/api/core/app/segments/parser.py b/api/core/app/segments/parser.pyindex 7061a4d878c..de6c7966525 100644--- a/api/core/app/segments/parser.py+++ b/api/core/app/segments/parser.py@@ -10,7 +10,7 @@ VARIABLE_PATTERN = re.compile(r'\{\{#([a-zA-Z0-9_]{1,50}(?:\.[a-zA-Z_][a-zA-Z0-9def convert_template(*, template: str, variable_pool: VariablePool):parts = re.split(VARIABLE_PATTERN, template)segments = []- for part in parts:+ for part in filter(lambda x: x, parts):if '.' in part and (value := variable_pool.get(part.split('.'))):segments.append(value)else:diff --git a/api/tests/unit_tests/core/app/test_segment.py b/api/tests/unit_tests/core/app/test_segment.pyindex 7ef37ff6466..414404b7d03 100644--- a/api/tests/unit_tests/core/app/test_segment.py+++ b/api/tests/unit_tests/core/app/test_segment.py@@ -1,4 +1,4 @@-from core.app.segments import SecretVariable, parser+from core.app.segments import SecretVariable, StringSegment, parserfrom core.helper import encrypterfrom core.workflow.entities.node_entities import SystemVariablefrom core.workflow.entities.variable_pool import VariablePool@@ -51,3 +51,4 @@ def test_convert_variable_to_segment_group():segments_group = parser.convert_template(template=template, variable_pool=variable_pool)assert segments_group.text == 'fake-user-id'assert segments_group.log == 'fake-user-id'+ assert segments_group.value == [StringSegment(value='fake-user-id')]