mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-22 21:48:12 -05:00
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:
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user