fix(api): Fix incorrect variable name for sys var.

This commit is contained in:
QuantumGhost 2025-05-22 17:35:07 +08:00
parent be098dee35
commit 35b4d2c499

View File

@ -1,4 +1,5 @@
import dataclasses
import logging
from collections.abc import Mapping, Sequence
from typing import Any
@ -15,6 +16,8 @@ from core.workflow.nodes import NodeType
from factories import variable_factory
from models.workflow import WorkflowDraftVariable, is_system_variable_editable
_logger = logging.getLogger(__name__)
@dataclasses.dataclass(frozen=True)
class WorkflowDraftVariableList:
@ -298,6 +301,24 @@ class _DraftVariableBuilder:
)
)
@staticmethod
def _normalize_variable_for_start_node(node_type: NodeType, node_id: str, name: str):
if node_type != NodeType.START:
return node_id, name
# TODO(QuantumGhost): need special handling for dummy output variable in
# `Start` node.
if not name.startswith(f"{SYSTEM_VARIABLE_NODE_ID}."):
return node_id, name
_logger.debug(
"Normalizing variable: node_type=%s, node_id=%s, name=%s",
node_type,
node_id,
name,
)
node_id, name_ = name.split(".", maxsplit=1)
return node_id, name_
def _build_variables_from_mapping(
self,
node_id: str,