LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
UN-3636 [FIX] Two OSS test fixes blocking the cloud rig integration tier (#2202)
Chandrasekharan Mb60dd6f3033c
diff --git a/backend/workflow_manager/endpoint_v2/tests/destination-connectors/test_destination_connector_postgres.py b/backend/workflow_manager/endpoint_v2/tests/destination-connectors/test_destination_connector_postgres.pyindex 445affba1..1b4a53187 100644--- a/backend/workflow_manager/endpoint_v2/tests/destination-connectors/test_destination_connector_postgres.py+++ b/backend/workflow_manager/endpoint_v2/tests/destination-connectors/test_destination_connector_postgres.py@@ -1,7 +1,6 @@import osfrom unittest.mock import Mock, patch-import pytestfrom django.test import TestCasefrom unstract.connectors.databases.postgresql import PostgreSQLfrom workflow_manager.endpoint_v2.constants import DestinationKey@@ -193,14 +192,6 @@ class TestDestinationConnectorPostgreSQL(TestCase):f"✅ Successfully inserted test data into PostgreSQL table: {self.test_table_name}")- @pytest.mark.xfail(- reason=(- "get_sql_values_for_query serializes data=None as the literal "- "string 'None', which is invalid JSON for the jsonb data column "- "(PR #2115 review). Remove this marker once None maps to SQL NULL."- ),- strict=True,- )def test_insert_into_db_with_error_postgresql(self) -> None:"""Test insertion with error parameter into real PostgreSQL database."""mock_workflow = self.create_mock_workflow()diff --git a/backend/workflow_manager/execution/tests/test_execution_serializer.py b/backend/workflow_manager/execution/tests/test_execution_serializer.pyindex f26370aea..7f72d3a42 100644--- a/backend/workflow_manager/execution/tests/test_execution_serializer.py+++ b/backend/workflow_manager/execution/tests/test_execution_serializer.py@@ -6,35 +6,18 @@ every non-successful file in a finished failure run has to land in ``failed``including files that never got a ``file_execution`` row. COMPLETED and live(PENDING/EXECUTING) runs keep the exact row-count behaviour.-DB-free and app-registry-free: the heavy ``WorkflowExecution`` model is stubbed-in ``sys.modules`` before importing the serializer (mirrors-``usage_v2/tests/test_helper.py`` / ``pg_queue/tests/test_producer.py``), so no-``django.setup()`` / live DB is needed — the methods under test are pure. The-real ``ExecutionStatus`` enum (no Django) is kept for its ``is_failure`` logic.+The methods under test are pure — they read counts off the passed object — so a+MagicMock stands in for WorkflowExecution and no DB is touched. The suite runs+under pytest-django (app registry loaded), so the serializer imports directly."""from __future__ import annotationsimport logging-import os-import sys-import typesfrom unittest.mock import MagicMock-# Force (not setdefault): a dev shell that already exports DJANGO_SETTINGS_MODULE-# (backend.settings.dev / .cloud) would otherwise redirect collection to a module-# that may not exist here. DRF reads settings lazily; no django.setup() is run.-os.environ["DJANGO_SETTINGS_MODULE"] = "backend.settings.test"--# Stub the model module so importing the serializer needs no app registry / DB.-_models_stub = types.ModuleType("workflow_manager.workflow_v2.models")-_models_stub.WorkflowExecution = type("WorkflowExecution", (), {})-sys.modules["workflow_manager.workflow_v2.models"] = _models_stub--from workflow_manager.execution.serializer.execution import ( # noqa: E402- ExecutionSerializer,-)-from workflow_manager.workflow_v2.enums import ExecutionStatus # noqa: E402+from workflow_manager.execution.serializer.execution import ExecutionSerializer+from workflow_manager.workflow_v2.enums import ExecutionStatus_LOGGER = "workflow_manager.execution.serializer.execution"_ids = iter(range(1, 100_000))diff --git a/unstract/connectors/src/unstract/connectors/databases/unstract_db.py b/unstract/connectors/src/unstract/connectors/databases/unstract_db.pyindex ce176724a..df673908a 100644--- a/unstract/connectors/src/unstract/connectors/databases/unstract_db.py+++ b/unstract/connectors/src/unstract/connectors/databases/unstract_db.py@@ -356,6 +356,10 @@ class UnstractDB(UnstractConnector, ABC):sql_values[column] = json.dumps(fallback_value)elif isinstance(value, Enum):sql_values[column] = value.value+ elif value is None:+ # Bind as SQL NULL; f"{None}" would write the literal "None",+ # invalid for a jsonb column (e.g. data on an errored record).+ sql_values[column] = Noneelse:sql_values[column] = f"{value}"