From 0c462c4b8745e303bdd4fcc32cc3b55516e70b59 Mon Sep 17 00:00:00 2001 From: QuantumGhost Date: Mon, 19 May 2025 20:45:18 +0800 Subject: [PATCH] feat(api): let `execution_metadata_dict` to return empty dict when the value is `None` --- .../sqlalchemy_workflow_node_execution_repository.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/api/core/repositories/sqlalchemy_workflow_node_execution_repository.py b/api/core/repositories/sqlalchemy_workflow_node_execution_repository.py index af7b261135..3bf775db13 100644 --- a/api/core/repositories/sqlalchemy_workflow_node_execution_repository.py +++ b/api/core/repositories/sqlalchemy_workflow_node_execution_repository.py @@ -4,13 +4,14 @@ SQLAlchemy implementation of the WorkflowNodeExecutionRepository. import json import logging -from collections.abc import Sequence -from typing import Optional, Union +from collections.abc import Mapping, Sequence +from typing import Any, Optional, Union, cast from sqlalchemy import UnaryExpression, asc, delete, desc, select from sqlalchemy.engine import Engine from sqlalchemy.orm import sessionmaker +from core.workflow.entities.node_entities import NodeRunMetadataKey from core.workflow.entities.node_execution_entities import ( NodeExecution, NodeExecutionStatus, @@ -122,7 +123,12 @@ class SQLAlchemyWorkflowNodeExecutionRepository(WorkflowNodeExecutionRepository) status=status, error=db_model.error, elapsed_time=db_model.elapsed_time, - metadata=metadata, + # FIXME(QuantumGhost): a temporary workaround for the following type check failure in Python 3.11. + # However, this problem is not occurred in Python 3.12. + # + # A case of this error is: + # https://github.com/langgenius/dify/actions/runs/15112698604/job/42475659482?pr=19737#step:9:24 + metadata=cast(Mapping[NodeRunMetadataKey, Any] | None, metadata), created_at=db_model.created_at, finished_at=db_model.finished_at, )