From 554e2beddf84640411b3e17e328a365be987324a Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Thu, 22 Jan 2026 19:08:14 -0500 Subject: [PATCH] fix(backend/hitl): address CodeRabbit review feedback - Use return_exceptions=True in asyncio.gather for auto-approval creation to prevent endpoint failure when auto-approval fails (reviews already processed) - Fix empty payload handling: use explicit None check instead of truthiness - Distinguish auto-approvals from normal approvals: auto-approvals always use current input_data, normal approvals preserve explicitly empty payloads --- .../api/features/executions/review/routes.py | 11 +++++++++-- .../backend/backend/blocks/helpers/review.py | 14 +++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/autogpt_platform/backend/backend/api/features/executions/review/routes.py b/autogpt_platform/backend/backend/api/features/executions/review/routes.py index 8bfa6c80c5..ac938f3dcc 100644 --- a/autogpt_platform/backend/backend/api/features/executions/review/routes.py +++ b/autogpt_platform/backend/backend/api/features/executions/review/routes.py @@ -216,12 +216,19 @@ async def process_review_action( payload=review.payload, ) - await asyncio.gather( + results = await asyncio.gather( *[ create_auto_approval_for_review(node_exec_id, review) for node_exec_id, review in approved_reviews - ] + ], + return_exceptions=True, ) + for result in results: + if isinstance(result, Exception): + logger.error( + "Failed to create auto-approval record", + exc_info=result, + ) # Count results approved_count = sum( diff --git a/autogpt_platform/backend/backend/blocks/helpers/review.py b/autogpt_platform/backend/backend/blocks/helpers/review.py index 68d6a9b5ab..b8f45ead38 100644 --- a/autogpt_platform/backend/backend/blocks/helpers/review.py +++ b/autogpt_platform/backend/backend/blocks/helpers/review.py @@ -106,8 +106,20 @@ class HITLReviewHelper: f"found existing approval" ) # Return a new ReviewResult with the current node_exec_id but approved status + # For auto-approvals, always use current input_data + # For normal approvals, use approval_result.data unless it's None + is_auto_approval = approval_result.node_exec_id != node_exec_id + approved_data = ( + input_data + if is_auto_approval + else ( + approval_result.data + if approval_result.data is not None + else input_data + ) + ) return ReviewResult( - data=approval_result.data if approval_result.data else input_data, + data=approved_data, status=ReviewStatus.APPROVED, message=approval_result.message, processed=True,