From 987a9da7993f7735a52468c5b66ffe0e28fcb4cf Mon Sep 17 00:00:00 2001 From: radu-mocanu Date: Mon, 3 Aug 2026 02:58:28 +0300 Subject: [PATCH] fix: categorize missing HITL index as deployment --- packages/uipath-platform/pyproject.toml | 2 +- .../platform/resume_triggers/_protocol.py | 52 +++++++++++-------- .../tests/services/test_hitl.py | 34 ++++++++++++ packages/uipath-platform/uv.lock | 2 +- packages/uipath/uv.lock | 2 +- 5 files changed, 68 insertions(+), 24 deletions(-) diff --git a/packages/uipath-platform/pyproject.toml b/packages/uipath-platform/pyproject.toml index 733852d36..f74c2bb87 100644 --- a/packages/uipath-platform/pyproject.toml +++ b/packages/uipath-platform/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-platform" -version = "0.2.15" +version = "0.2.16" description = "HTTP client library for programmatic access to UiPath Platform" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/packages/uipath-platform/src/uipath/platform/resume_triggers/_protocol.py b/packages/uipath-platform/src/uipath/platform/resume_triggers/_protocol.py index 784e9f2ae..ab924adc6 100644 --- a/packages/uipath-platform/src/uipath/platform/resume_triggers/_protocol.py +++ b/packages/uipath-platform/src/uipath/platform/resume_triggers/_protocol.py @@ -60,6 +60,7 @@ from uipath.platform.errors import ( BatchTransformFailedException, BatchTransformNotCompleteException, + ContextGroundingIndexNotFoundError, OperationNotCompleteException, ) from uipath.platform.orchestrator.job import JobState @@ -544,6 +545,8 @@ async def create_trigger(self, suspend_value: Any) -> UiPathResumeTrigger: f"Unexpected model received" f"{type(suspend_value)} is not a valid Human-In-The-Loop model", ) + except UiPathFaultedTriggerError: + raise except Exception as e: raise UiPathFaultedTriggerError( ErrorCategory.SYSTEM, @@ -778,27 +781,34 @@ async def _handle_batch_rag_job_trigger( resume_trigger.item_key = value.batch_transform.id elif isinstance(value, CreateBatchTransform): uipath = UiPath() - if value.is_ephemeral_index: - batch_transform = await uipath.context_grounding.start_batch_transform_ephemeral_async( - name=value.name, - index_id=value.index_id, - prompt=value.prompt, - output_columns=value.output_columns, - storage_bucket_folder_path_prefix=value.storage_bucket_folder_path_prefix, - enable_web_search_grounding=value.enable_web_search_grounding, - ) - else: - batch_transform = await uipath.context_grounding.start_batch_transform_async( - name=value.name, - index_name=value.index_name, - index_id=value.index_id, - prompt=value.prompt, - output_columns=value.output_columns, - storage_bucket_folder_path_prefix=value.storage_bucket_folder_path_prefix, - enable_web_search_grounding=value.enable_web_search_grounding, - folder_path=value.index_folder_path, - folder_key=value.index_folder_key, - ) + try: + if value.is_ephemeral_index: + batch_transform = await uipath.context_grounding.start_batch_transform_ephemeral_async( + name=value.name, + index_id=value.index_id, + prompt=value.prompt, + output_columns=value.output_columns, + storage_bucket_folder_path_prefix=value.storage_bucket_folder_path_prefix, + enable_web_search_grounding=value.enable_web_search_grounding, + ) + else: + batch_transform = await uipath.context_grounding.start_batch_transform_async( + name=value.name, + index_name=value.index_name, + index_id=value.index_id, + prompt=value.prompt, + output_columns=value.output_columns, + storage_bucket_folder_path_prefix=value.storage_bucket_folder_path_prefix, + enable_web_search_grounding=value.enable_web_search_grounding, + folder_path=value.index_folder_path, + folder_key=value.index_folder_key, + ) + except ContextGroundingIndexNotFoundError as e: + raise UiPathFaultedTriggerError( + ErrorCategory.DEPLOYMENT, + "Context grounding index not found", + str(e), + ) from e if not batch_transform: raise Exception("Failed to start batch transform") diff --git a/packages/uipath-platform/tests/services/test_hitl.py b/packages/uipath-platform/tests/services/test_hitl.py index 134d75fc0..2f7bbb353 100644 --- a/packages/uipath-platform/tests/services/test_hitl.py +++ b/packages/uipath-platform/tests/services/test_hitl.py @@ -67,6 +67,7 @@ StartExtractionValidationResponse, ValidateExtractionAction, ) +from uipath.platform.errors import ContextGroundingIndexNotFoundError from uipath.platform.orchestrator import Job, JobErrorInfo from uipath.platform.orchestrator.job import JobState from uipath.platform.resume_triggers import ( @@ -1832,6 +1833,39 @@ async def test_create_resume_trigger_create_batch_transform( folder_key=create_batch_transform.index_folder_key, ) + @pytest.mark.anyio + async def test_missing_batch_transform_index_is_deployment_error( + self, + setup_test_env: None, + ) -> None: + create_batch_transform = CreateBatchTransform( + name="test-batch-transform", + index_name="Files", + prompt="test prompt", + output_columns=[ + BatchTransformOutputColumn(name="column1", description="desc1") + ], + destination_path="/output/path.xlsx", + index_folder_path="/test/path", + ) + missing_index = ContextGroundingIndexNotFoundError("Files") + mock_start_batch_transform = AsyncMock(side_effect=missing_index) + + with patch( + "uipath.platform.context_grounding._context_grounding_service.ContextGroundingService.start_batch_transform_async", + new=mock_start_batch_transform, + ): + with pytest.raises(UiPathFaultedTriggerError) as exc_info: + await UiPathResumeTriggerCreator().create_trigger( + create_batch_transform + ) + + error = exc_info.value + assert error.category == ErrorCategory.DEPLOYMENT + assert error.message == "Context grounding index not found" + assert error.detail == "ContextGroundingIndex 'Files' not found" + assert error.__cause__ is missing_index + @pytest.mark.anyio async def test_create_resume_trigger_wait_batch_transform( self, diff --git a/packages/uipath-platform/uv.lock b/packages/uipath-platform/uv.lock index 4aa68776a..f5331a448 100644 --- a/packages/uipath-platform/uv.lock +++ b/packages/uipath-platform/uv.lock @@ -1095,7 +1095,7 @@ dev = [ [[package]] name = "uipath-platform" -version = "0.2.15" +version = "0.2.16" source = { editable = "." } dependencies = [ { name = "anyio" }, diff --git a/packages/uipath/uv.lock b/packages/uipath/uv.lock index 0356dc28d..208b7064f 100644 --- a/packages/uipath/uv.lock +++ b/packages/uipath/uv.lock @@ -2760,7 +2760,7 @@ wheels = [ [[package]] name = "uipath-platform" -version = "0.2.15" +version = "0.2.16" source = { editable = "../uipath-platform" } dependencies = [ { name = "anyio" },