From e08843485ff99094f004ce114206f922c8faee3c Mon Sep 17 00:00:00 2001 From: Gabriel Luiz Freitas Almeida Date: Tue, 28 Nov 2023 14:34:50 -0300 Subject: [PATCH] Fix task status handling and update custom component field --- src/backend/langflow/api/v1/endpoints.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/langflow/api/v1/endpoints.py b/src/backend/langflow/api/v1/endpoints.py index 51d3e8bad..0366c6a97 100644 --- a/src/backend/langflow/api/v1/endpoints.py +++ b/src/backend/langflow/api/v1/endpoints.py @@ -160,6 +160,10 @@ async def get_task_status(task_id: str): result = None if task.ready(): result = task.result + # If result isinstance of Exception, can we get the traceback? + if isinstance(result, Exception): + logger.exception(task.traceback) + if isinstance(result, dict) and "result" in result: result = result["result"] elif hasattr(result, "result"): @@ -167,6 +171,10 @@ async def get_task_status(task_id: str): if task is None: raise HTTPException(status_code=404, detail="Task not found") + if task.status == "FAILURE": + result = str(task.result) + logger.error(f"Task {task_id} failed: {task.traceback}") + return TaskStatusResponse(status=task.status, result=result) @@ -237,3 +245,7 @@ async def custom_component_update( component_node = build_langchain_template_custom_component(component, user_id=user.id, update_field=raw_code.field) # Update the field return component_node + # Update the field + return component_node + # Update the field + return component_node