Skip to content

Commit dde2c9e

Browse files
UN-2932 [FIX] hitl rules check issue fix (#1648)
hitl rules check issue fix
1 parent ee6e983 commit dde2c9e

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

workers/shared/workflow/destination_connector.py

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def _check_and_handle_hitl(
461461
file_hash=file_ctx.file_hash,
462462
workflow=file_ctx.workflow,
463463
api_client=exec_ctx.api_client,
464+
tool_execution_result=result.tool_execution_result,
464465
error=file_ctx.execution_error,
465466
)
466467

@@ -1423,9 +1424,6 @@ def _should_handle_hitl(
14231424
f"{file_name}: Skipping HITL validation as we're not using file_history"
14241425
)
14251426
return False
1426-
if not file_hash.is_manualreview_required:
1427-
logger.info(f"{file_name}: File is not marked for manual review")
1428-
return False
14291427

14301428
# Use class-level manual review service
14311429
manual_review_service = self._ensure_manual_review_service(api_client)
@@ -1434,8 +1432,40 @@ def _should_handle_hitl(
14341432
return False
14351433

14361434
workflow_util = manual_review_service.get_workflow_util()
1435+
1436+
# Don't skip rule evaluation just because file wasn't pre-selected by percentage
1437+
# validate_db_rule will check both percentage selection AND rules with OR/AND logic
1438+
if not file_hash.is_manualreview_required:
1439+
logger.info(
1440+
f"{file_name}: File not pre-selected by percentage, "
1441+
f"but checking if rules match..."
1442+
)
1443+
1444+
# Wrap tool_execution_result in the expected structure for rule evaluation
1445+
# validate_db_rule expects: {"output": {...}, "metadata": {...}}
1446+
wrapped_result = None
1447+
if tool_execution_result:
1448+
if isinstance(tool_execution_result, dict):
1449+
# Check if tool_execution_result already has the correct structure
1450+
if "output" in tool_execution_result:
1451+
# Already in correct format, use as-is
1452+
wrapped_result = tool_execution_result
1453+
logger.debug(
1454+
f"{file_name}: tool_execution_result already has 'output' key, using as-is"
1455+
)
1456+
else:
1457+
# Wrap it in the expected structure
1458+
wrapped_result = {"output": tool_execution_result, "metadata": {}}
1459+
logger.debug(
1460+
f"{file_name}: Wrapped tool_execution_result in output/metadata structure"
1461+
)
1462+
else:
1463+
logger.warning(
1464+
f"{file_name}: tool_execution_result is not a dict: {type(tool_execution_result)}"
1465+
)
1466+
14371467
is_to_hitl = workflow_util.validate_db_rule(
1438-
tool_execution_result,
1468+
wrapped_result,
14391469
workflow,
14401470
file_hash.file_destination,
14411471
file_hash.is_manualreview_required,

0 commit comments

Comments
 (0)