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
This commit is contained in:
Zamil Majdy
2026-01-22 19:08:14 -05:00
parent 29fdda3fa8
commit 554e2beddf
2 changed files with 22 additions and 3 deletions

View File

@@ -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(

View File

@@ -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,