Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-2932 [FIX] hitl rules check issue fix (#1648)

vishnuszipstackdde2c9ef41e8
diff --git a/workers/shared/workflow/destination_connector.py b/workers/shared/workflow/destination_connector.py
index 8d8ca3e25..05de89c27 100644
--- a/workers/shared/workflow/destination_connector.py
+++ b/workers/shared/workflow/destination_connector.py
@@ -461,6 +461,7 @@ class WorkerDestinationConnector:
file_hash=file_ctx.file_hash,
workflow=file_ctx.workflow,
api_client=exec_ctx.api_client,
+ tool_execution_result=result.tool_execution_result,
error=file_ctx.execution_error,
)
@@ -1423,9 +1424,6 @@ class WorkerDestinationConnector:
f"{file_name}: Skipping HITL validation as we're not using file_history"
)
return False
- if not file_hash.is_manualreview_required:
- logger.info(f"{file_name}: File is not marked for manual review")
- return False
# Use class-level manual review service
manual_review_service = self._ensure_manual_review_service(api_client)
@@ -1434,8 +1432,40 @@ class WorkerDestinationConnector:
return False
workflow_util = manual_review_service.get_workflow_util()
+
+ # Don't skip rule evaluation just because file wasn't pre-selected by percentage
+ # validate_db_rule will check both percentage selection AND rules with OR/AND logic
+ if not file_hash.is_manualreview_required:
+ logger.info(
+ f"{file_name}: File not pre-selected by percentage, "
+ f"but checking if rules match..."
+ )
+
+ # Wrap tool_execution_result in the expected structure for rule evaluation
+ # validate_db_rule expects: {"output": {...}, "metadata": {...}}
+ wrapped_result = None
+ if tool_execution_result:
+ if isinstance(tool_execution_result, dict):
+ # Check if tool_execution_result already has the correct structure
+ if "output" in tool_execution_result:
+ # Already in correct format, use as-is
+ wrapped_result = tool_execution_result
+ logger.debug(
+ f"{file_name}: tool_execution_result already has 'output' key, using as-is"
+ )
+ else:
+ # Wrap it in the expected structure
+ wrapped_result = {"output": tool_execution_result, "metadata": {}}
+ logger.debug(
+ f"{file_name}: Wrapped tool_execution_result in output/metadata structure"
+ )
+ else:
+ logger.warning(
+ f"{file_name}: tool_execution_result is not a dict: {type(tool_execution_result)}"
+ )
+
is_to_hitl = workflow_util.validate_db_rule(
- tool_execution_result,
+ wrapped_result,
workflow,
file_hash.file_destination,
file_hash.is_manualreview_required,