diff --git a/src/backend/base/langflow/graph/graph/base.py b/src/backend/base/langflow/graph/graph/base.py index b66c22ac2..e5986fcb9 100644 --- a/src/backend/base/langflow/graph/graph/base.py +++ b/src/backend/base/langflow/graph/graph/base.py @@ -1689,14 +1689,15 @@ class Graph: t.cancel() raise result if isinstance(result, VertexBuildResult): - await log_vertex_build( - flow_id=self.flow_id or "", - vertex_id=result.vertex.id, - valid=result.valid, - params=result.params, - data=result.result_dict, - artifacts=result.artifacts, - ) + if self.flow_id is not None: + await log_vertex_build( + flow_id=self.flow_id, + vertex_id=result.vertex.id, + valid=result.valid, + params=result.params, + data=result.result_dict, + artifacts=result.artifacts, + ) vertices.append(result.vertex) else: diff --git a/src/backend/base/langflow/graph/utils.py b/src/backend/base/langflow/graph/utils.py index e35d6faed..cac41a6a2 100644 --- a/src/backend/base/langflow/graph/utils.py +++ b/src/backend/base/langflow/graph/utils.py @@ -166,7 +166,7 @@ async def log_transaction( async def log_vertex_build( *, - flow_id: str, + flow_id: str | UUID, vertex_id: str, valid: bool, params: Any, @@ -181,9 +181,15 @@ async def log_vertex_build( try: if not get_settings_service().settings.vertex_builds_storage_enabled: return + try: + if isinstance(flow_id, str): + flow_id = UUID(flow_id) + except ValueError: + msg = f"Invalid flow_id passed to log_vertex_build: {flow_id!r}(type: {type(flow_id)})" + raise ValueError(msg) from None vertex_build = VertexBuildBase( - flow_id=flow_id if isinstance(flow_id, UUID) else UUID(flow_id), + flow_id=flow_id, id=vertex_id, valid=valid, params=str(params) if params else None,