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
refactor: move SegmentAttachmentBinding and UploadFile to TypeBase (#30218)
Asuka Minato1065a4840aa3
diff --git a/api/models/model.py b/api/models/model.pyindex de83aa1d969..25c330b062b 100644--- a/api/models/model.py+++ b/api/models/model.py@@ -2182,7 +2182,7 @@ class ApiToken(Base): # bug: this uses setattr so idk the field.return result-class UploadFile(Base):+class UploadFile(TypeBase):__tablename__ = "upload_files"__table_args__ = (sa.PrimaryKeyConstraint("id", name="upload_file_pkey"),@@ -2190,9 +2190,12 @@ class UploadFile(Base):)# NOTE: The `id` field is generated within the application to minimize extra roundtrips- # (especially when generating `source_url`).- # The `server_default` serves as a fallback mechanism.- id: Mapped[str] = mapped_column(StringUUID, default=lambda: str(uuid4()))+ # (especially when generating `source_url`) and keep model metadata portable across databases.+ id: Mapped[str] = mapped_column(+ StringUUID,+ init=False,+ default_factory=lambda: str(uuid4()),+ )tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)storage_type: Mapped[StorageType] = mapped_column(EnumText(StorageType, length=255), nullable=False)key: Mapped[str] = mapped_column(String(255), nullable=False)@@ -2200,16 +2203,6 @@ class UploadFile(Base):size: Mapped[int] = mapped_column(sa.Integer, nullable=False)extension: Mapped[str] = mapped_column(String(255), nullable=False)mime_type: Mapped[str] = mapped_column(String(255), nullable=True)-- # The `created_by_role` field indicates whether the file was created by an `Account` or an `EndUser`.- # Its value is derived from the `CreatorUserRole` enumeration.- created_by_role: Mapped[CreatorUserRole] = mapped_column(- EnumText(CreatorUserRole, length=255),- nullable=False,- server_default=sa.text("'account'"),- default=CreatorUserRole.ACCOUNT,- )-# The `created_by` field stores the ID of the entity that created this upload file.## If `created_by_role` is `ACCOUNT`, it corresponds to `Account.id`.@@ -2228,10 +2221,18 @@ class UploadFile(Base):# `used` may indicate whether the file has been utilized by another service.used: Mapped[bool] = mapped_column(sa.Boolean, nullable=False, server_default=sa.text("false"))+ # The `created_by_role` field indicates whether the file was created by an `Account` or an `EndUser`.+ # Its value is derived from the `CreatorUserRole` enumeration.+ created_by_role: Mapped[CreatorUserRole] = mapped_column(+ EnumText(CreatorUserRole, length=255),+ nullable=False,+ server_default=sa.text("'account'"),+ default=CreatorUserRole.ACCOUNT,+ )# `used_by` may indicate the ID of the user who utilized this file.- used_by: Mapped[str | None] = mapped_column(StringUUID, nullable=True)- used_at: Mapped[datetime | None] = mapped_column(sa.DateTime, nullable=True)- hash: Mapped[str | None] = mapped_column(String(255), nullable=True)+ used_by: Mapped[str | None] = mapped_column(StringUUID, nullable=True, default=None)+ used_at: Mapped[datetime | None] = mapped_column(sa.DateTime, nullable=True, default=None)+ hash: Mapped[str | None] = mapped_column(String(255), nullable=True, default=None)source_url: Mapped[str] = mapped_column(LongText, default="")def __init__(diff --git a/api/models/workflow.py b/api/models/workflow.pyindex d127244b0f2..cb1723440b8 100644--- a/api/models/workflow.py+++ b/api/models/workflow.py@@ -50,7 +50,7 @@ from libs.uuid_utils import uuidv7from ._workflow_exc import NodeNotFoundError, WorkflowDataErrorif TYPE_CHECKING:- from .model import AppMode, UploadFile+ from .model import AppModefrom constants import DEFAULT_FILE_NUMBER_LIMITS, HIDDEN_VALUE@@ -63,6 +63,10 @@ from .account import Accountfrom .base import Base, DefaultFieldsDCMixin, TypeBasefrom .engine import dbfrom .enums import CreatorUserRole, DraftVariableType, ExecutionOffLoadType, WorkflowRunTriggeredFrom++# UploadFile uses TypeBase while workflow execution offload models use Base, so relationships+# must target the class object directly instead of relying on string lookup across registries.+from .model import UploadFilefrom .types import EnumText, LongText, StringUUIDfrom .utils.file_input_compat import (build_file_from_mapping_without_lookup,@@ -1096,8 +1100,6 @@ class WorkflowNodeExecutionModel(Base): # This model is expected to have `offlo@staticmethoddef _load_full_content(session: orm.Session, file_id: str, storage: Storage):- from .model import UploadFile-stmt = sa.select(UploadFile).where(UploadFile.id == file_id)file = session.scalars(stmt).first()assert file is not None, f"UploadFile with id {file_id} should exist but not"@@ -1191,10 +1193,11 @@ class WorkflowNodeExecutionOffload(Base):)file: Mapped[Optional["UploadFile"]] = orm.relationship(+ UploadFile,foreign_keys=[file_id],lazy="raise",uselist=False,- primaryjoin="WorkflowNodeExecutionOffload.file_id == UploadFile.id",+ primaryjoin=lambda: orm.foreign(WorkflowNodeExecutionOffload.file_id) == UploadFile.id,)@@ -1968,10 +1971,11 @@ class WorkflowDraftVariableFile(Base):# Relationship to UploadFileupload_file: Mapped["UploadFile"] = orm.relationship(+ UploadFile,foreign_keys=[upload_file_id],lazy="raise",uselist=False,- primaryjoin="WorkflowDraftVariableFile.upload_file_id == UploadFile.id",+ primaryjoin=lambda: orm.foreign(WorkflowDraftVariableFile.upload_file_id) == UploadFile.id,)diff --git a/api/tests/unit_tests/models/test_workflow_models.py b/api/tests/unit_tests/models/test_workflow_models.pyindex eb9fef75878..0953570a315 100644--- a/api/tests/unit_tests/models/test_workflow_models.py+++ b/api/tests/unit_tests/models/test_workflow_models.py@@ -45,7 +45,7 @@ class TestWorkflowModelValidation:workflow = Workflow.new(tenant_id=tenant_id,app_id=app_id,- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=graph,features=features,@@ -58,7 +58,7 @@ class TestWorkflowModelValidation:# Assertassert workflow.tenant_id == tenant_idassert workflow.app_id == app_id- assert workflow.type == WorkflowType.WORKFLOW.value+ assert workflow.type == WorkflowType.WORKFLOWassert workflow.version == "draft"assert workflow.graph == graphassert workflow.created_by == created_by@@ -68,7 +68,7 @@ class TestWorkflowModelValidation:def test_workflow_type_enum_values(self):"""Test WorkflowType enum values."""# Assert- assert WorkflowType.WORKFLOW.value == "workflow"+ assert WorkflowType.WORKFLOW == "workflow"assert WorkflowType.CHAT.value == "chat"assert WorkflowType.RAG_PIPELINE.value == "rag-pipeline"@@ -89,7 +89,7 @@ class TestWorkflowModelValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=json.dumps(graph_data),features="{}",@@ -114,7 +114,7 @@ class TestWorkflowModelValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph="{}",features=json.dumps(features_data),@@ -138,7 +138,7 @@ class TestWorkflowModelValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="v1.0",graph="{}",features="{}",@@ -176,11 +176,11 @@ class TestWorkflowRunStateTransitions:tenant_id=tenant_id,app_id=app_id,workflow_id=workflow_id,- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.DEBUGGING.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.DEBUGGING,version="draft",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=created_by,)@@ -188,9 +188,9 @@ class TestWorkflowRunStateTransitions:assert workflow_run.tenant_id == tenant_idassert workflow_run.app_id == app_idassert workflow_run.workflow_id == workflow_id- assert workflow_run.type == WorkflowType.WORKFLOW.value- assert workflow_run.triggered_from == WorkflowRunTriggeredFrom.DEBUGGING.value- assert workflow_run.status == WorkflowExecutionStatus.RUNNING.value+ assert workflow_run.type == WorkflowType.WORKFLOW+ assert workflow_run.triggered_from == WorkflowRunTriggeredFrom.DEBUGGING+ assert workflow_run.status == WorkflowExecutionStatus.RUNNINGassert workflow_run.created_by == created_bydef test_workflow_run_state_transition_running_to_succeeded(self):@@ -200,21 +200,21 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.END_USER.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.END_USER,created_by=str(uuid4()),)# Act- workflow_run.status = WorkflowExecutionStatus.SUCCEEDED.value+ workflow_run.status = WorkflowExecutionStatus.SUCCEEDEDworkflow_run.finished_at = datetime.now(UTC)workflow_run.elapsed_time = 2.5# Assert- assert workflow_run.status == WorkflowExecutionStatus.SUCCEEDED.value+ assert workflow_run.status == WorkflowExecutionStatus.SUCCEEDEDassert workflow_run.finished_at is not Noneassert workflow_run.elapsed_time == 2.5@@ -225,21 +225,21 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)# Act- workflow_run.status = WorkflowExecutionStatus.FAILED.value+ workflow_run.status = WorkflowExecutionStatus.FAILEDworkflow_run.error = "Node execution failed: Invalid input"workflow_run.finished_at = datetime.now(UTC)# Assert- assert workflow_run.status == WorkflowExecutionStatus.FAILED.value+ assert workflow_run.status == WorkflowExecutionStatus.FAILEDassert workflow_run.error == "Node execution failed: Invalid input"assert workflow_run.finished_at is not None@@ -250,20 +250,20 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.DEBUGGING.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.DEBUGGING,version="draft",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)# Act- workflow_run.status = WorkflowExecutionStatus.STOPPED.value+ workflow_run.status = WorkflowExecutionStatus.STOPPEDworkflow_run.finished_at = datetime.now(UTC)# Assert- assert workflow_run.status == WorkflowExecutionStatus.STOPPED.value+ assert workflow_run.status == WorkflowExecutionStatus.STOPPEDassert workflow_run.finished_at is not Nonedef test_workflow_run_state_transition_running_to_paused(self):@@ -273,19 +273,19 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.END_USER.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.END_USER,created_by=str(uuid4()),)# Act- workflow_run.status = WorkflowExecutionStatus.PAUSED.value+ workflow_run.status = WorkflowExecutionStatus.PAUSED# Assert- assert workflow_run.status == WorkflowExecutionStatus.PAUSED.value+ assert workflow_run.status == WorkflowExecutionStatus.PAUSEDassert workflow_run.finished_at is None # Not finished when pauseddef test_workflow_run_state_transition_paused_to_running(self):@@ -295,19 +295,19 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.PAUSED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.PAUSED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)# Act- workflow_run.status = WorkflowExecutionStatus.RUNNING.value+ workflow_run.status = WorkflowExecutionStatus.RUNNING# Assert- assert workflow_run.status == WorkflowExecutionStatus.RUNNING.value+ assert workflow_run.status == WorkflowExecutionStatus.RUNNINGdef test_workflow_run_with_partial_succeeded_status(self):"""Test workflow run with partial-succeeded status."""@@ -316,17 +316,17 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.PARTIAL_SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.PARTIAL_SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),exceptions_count=2,)# Assert- assert workflow_run.status == WorkflowExecutionStatus.PARTIAL_SUCCEEDED.value+ assert workflow_run.status == WorkflowExecutionStatus.PARTIAL_SUCCEEDEDassert workflow_run.exceptions_count == 2def test_workflow_run_with_inputs_and_outputs(self):@@ -340,11 +340,11 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.END_USER.value,+ status=WorkflowExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.END_USER,created_by=str(uuid4()),inputs=json.dumps(inputs),outputs=json.dumps(outputs),@@ -362,11 +362,11 @@ class TestWorkflowRunStateTransitions:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.DEBUGGING.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.DEBUGGING,version="draft",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),graph=json.dumps(graph),)@@ -391,11 +391,11 @@ class TestWorkflowRunStateTransitions:tenant_id=tenant_id,app_id=app_id,workflow_id=workflow_id,- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=created_by,total_tokens=1500,total_steps=5,@@ -410,7 +410,7 @@ class TestWorkflowRunStateTransitions:assert result["tenant_id"] == tenant_idassert result["app_id"] == app_idassert result["workflow_id"] == workflow_id- assert result["status"] == WorkflowExecutionStatus.SUCCEEDED.value+ assert result["status"] == WorkflowExecutionStatus.SUCCEEDEDassert result["total_tokens"] == 1500assert result["total_steps"] == 5@@ -422,18 +422,18 @@ class TestWorkflowRunStateTransitions:"tenant_id": str(uuid4()),"app_id": str(uuid4()),"workflow_id": str(uuid4()),- "type": WorkflowType.WORKFLOW.value,- "triggered_from": WorkflowRunTriggeredFrom.APP_RUN.value,+ "type": WorkflowType.WORKFLOW,+ "triggered_from": WorkflowRunTriggeredFrom.APP_RUN,"version": "v1.0","graph": {"nodes": [], "edges": []},"inputs": {"query": "test"},- "status": WorkflowExecutionStatus.SUCCEEDED.value,+ "status": WorkflowExecutionStatus.SUCCEEDED,"outputs": {"result": "success"},"error": None,"elapsed_time": 3.5,"total_tokens": 2000,"total_steps": 10,- "created_by_role": CreatorUserRole.ACCOUNT.value,+ "created_by_role": CreatorUserRole.ACCOUNT,"created_by": str(uuid4()),"created_at": datetime.now(UTC),"finished_at": datetime.now(UTC),@@ -446,7 +446,7 @@ class TestWorkflowRunStateTransitions:# Assertassert workflow_run.id == data["id"]assert workflow_run.workflow_id == data["workflow_id"]- assert workflow_run.status == WorkflowExecutionStatus.SUCCEEDED.value+ assert workflow_run.status == WorkflowExecutionStatus.SUCCEEDEDassert workflow_run.total_tokens == 2000@@ -467,14 +467,14 @@ class TestNodeExecutionRelationships:tenant_id=tenant_id,app_id=app_id,workflow_id=workflow_id,- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=workflow_run_id,index=1,node_id="start",node_type=BuiltinNodeTypes.START,title="Start Node",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=created_by,)@@ -498,15 +498,15 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=2,predecessor_node_id=predecessor_node_id,node_id=current_node_id,node_type=BuiltinNodeTypes.LLM,title="LLM Node",- status=WorkflowNodeExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)@@ -528,8 +528,8 @@ class TestNodeExecutionRelationships:node_id="llm_test",node_type=BuiltinNodeTypes.LLM,title="Test LLM",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)@@ -549,14 +549,14 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id="llm_1",node_type=BuiltinNodeTypes.LLM,title="LLM Node",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),inputs=json.dumps(inputs),outputs=json.dumps(outputs),@@ -575,24 +575,24 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id="code_1",node_type=BuiltinNodeTypes.CODE,title="Code Node",- status=WorkflowNodeExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)# Act - transition to succeeded- node_execution.status = WorkflowNodeExecutionStatus.SUCCEEDED.value+ node_execution.status = WorkflowNodeExecutionStatus.SUCCEEDEDnode_execution.elapsed_time = 1.2node_execution.finished_at = datetime.now(UTC)# Assert- assert node_execution.status == WorkflowNodeExecutionStatus.SUCCEEDED.value+ assert node_execution.status == WorkflowNodeExecutionStatus.SUCCEEDEDassert node_execution.elapsed_time == 1.2assert node_execution.finished_at is not None@@ -606,20 +606,20 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=3,node_id="code_1",node_type=BuiltinNodeTypes.CODE,title="Code Node",- status=WorkflowNodeExecutionStatus.FAILED.value,+ status=WorkflowNodeExecutionStatus.FAILED,error=error_message,- created_by_role=CreatorUserRole.ACCOUNT.value,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)# Assert- assert node_execution.status == WorkflowNodeExecutionStatus.FAILED.value+ assert node_execution.status == WorkflowNodeExecutionStatus.FAILEDassert node_execution.error == error_messagedef test_node_execution_with_metadata(self):@@ -637,14 +637,14 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id="llm_1",node_type=BuiltinNodeTypes.LLM,title="LLM Node",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),execution_metadata=json.dumps(metadata),)@@ -660,14 +660,14 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id="start",node_type=BuiltinNodeTypes.START,title="Start",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),execution_metadata=None,)@@ -696,14 +696,14 @@ class TestNodeExecutionRelationships:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id=f"{node_type}_1",node_type=node_type,title=title,- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),)@@ -734,7 +734,7 @@ class TestGraphConfigurationValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=json.dumps(graph_config),features="{}",@@ -761,7 +761,7 @@ class TestGraphConfigurationValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=json.dumps(graph_config),features="{}",@@ -802,7 +802,7 @@ class TestGraphConfigurationValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=json.dumps(graph_config),features="{}",@@ -835,11 +835,11 @@ class TestGraphConfigurationValidation:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),graph=json.dumps(original_graph),)@@ -872,7 +872,7 @@ class TestGraphConfigurationValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=json.dumps(graph_config),features="{}",@@ -912,7 +912,7 @@ class TestGraphConfigurationValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=json.dumps(graph_config),features="{}",@@ -933,7 +933,7 @@ class TestGraphConfigurationValidation:workflow = Workflow.new(tenant_id=str(uuid4()),app_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,+ type=WorkflowType.WORKFLOW,version="draft",graph=None,features="{}",@@ -956,11 +956,11 @@ class TestGraphConfigurationValidation:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),inputs=None,)@@ -978,11 +978,11 @@ class TestGraphConfigurationValidation:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- type=WorkflowType.WORKFLOW.value,- triggered_from=WorkflowRunTriggeredFrom.APP_RUN.value,+ type=WorkflowType.WORKFLOW,+ triggered_from=WorkflowRunTriggeredFrom.APP_RUN,version="v1.0",- status=WorkflowExecutionStatus.RUNNING.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowExecutionStatus.RUNNING,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),outputs=None,)@@ -1000,14 +1000,14 @@ class TestGraphConfigurationValidation:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id="start",node_type=BuiltinNodeTypes.START,title="Start",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),inputs=None,)@@ -1025,14 +1025,14 @@ class TestGraphConfigurationValidation:tenant_id=str(uuid4()),app_id=str(uuid4()),workflow_id=str(uuid4()),- triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN.value,+ triggered_from=WorkflowNodeExecutionTriggeredFrom.WORKFLOW_RUN,workflow_run_id=str(uuid4()),index=1,node_id="start",node_type=BuiltinNodeTypes.START,title="Start",- status=WorkflowNodeExecutionStatus.SUCCEEDED.value,- created_by_role=CreatorUserRole.ACCOUNT.value,+ status=WorkflowNodeExecutionStatus.SUCCEEDED,+ created_by_role=CreatorUserRole.ACCOUNT,created_by=str(uuid4()),outputs=None,)