From 240b75ca4c4ed7d17ebf24f9acedf29b35ed9356 Mon Sep 17 00:00:00 2001 From: LawyZheng Date: Sun, 5 Jan 2025 18:42:40 +0800 Subject: [PATCH] fix forloop output parameter issue (#1490) --- skyvern/forge/sdk/workflow/models/block.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.py index 7ff3fadc20..c7405170d0 100644 --- a/skyvern/forge/sdk/workflow/models/block.py +++ b/skyvern/forge/sdk/workflow/models/block.py @@ -458,9 +458,13 @@ async def execute( try: self.format_potential_template_parameters(workflow_run_context=workflow_run_context) except Exception as e: + failure_reason = f"Failed to format jinja template: {str(e)}" + await self.record_output_parameter_value( + workflow_run_context, workflow_run_id, {"failure_reason": failure_reason} + ) return await self.build_block_result( success=False, - failure_reason=f"Failed to format jinja template: {str(e)}", + failure_reason=failure_reason, output_parameter_value=None, status=BlockStatus.failed, workflow_run_block_id=workflow_run_block_id, @@ -843,7 +847,9 @@ async def execute_loop_helper( { "loop_value": loop_over_value, "output_parameter": block_output.output_parameter, - "output_value": workflow_run_context.get_value(block_output.output_parameter.key), + "output_value": workflow_run_context.get_value(block_output.output_parameter.key) + if workflow_run_context.has_value(block_output.output_parameter.key) + else None, } ) try: