Skip to content

Commit 507935e

Browse files
committed
fix: folder path error handling
1 parent 95b546d commit 507935e

File tree

6 files changed

+68
-3
lines changed

6 files changed

+68
-3
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-mcp"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "UiPath MCP SDK"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"
@@ -48,6 +48,7 @@ dev = [
4848
"filelock>=3.20.3",
4949
"virtualenv>=20.36.1",
5050
"numpy>=1.24.0",
51+
"pytest-asyncio>=1.3.0",
5152
]
5253

5354
[tool.ruff]

src/uipath_mcp/_cli/_runtime/_runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ async def _run_server(self) -> UiPathRuntimeResult:
195195
raise UiPathMcpRuntimeError(
196196
McpErrorCode.REGISTRATION_ERROR,
197197
"Folder NOT FOUND. Invalid UIPATH_FOLDER_PATH environment variable.",
198-
"Please set the UIPATH_FOLDER_PATH or UIPATH_FOLDER_KEY environment variable.",
198+
f"The folder '{folder_path}' was not found. Please verify that UIPATH_FOLDER_PATH is set to a valid folder path, or use UIPATH_FOLDER_KEY instead.",
199199
UiPathErrorCategory.USER,
200200
)
201201

tests/__init__.py

Whitespace-only changes.

tests/cli/__init__.py

Whitespace-only changes.

tests/cli/test_runtime.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from unittest.mock import MagicMock, patch
2+
3+
import pytest
4+
from uipath._utils.constants import ENV_FOLDER_PATH
5+
6+
from uipath_mcp._cli._runtime._exception import UiPathMcpRuntimeError
7+
from uipath_mcp._cli._runtime._runtime import UiPathMcpRuntime
8+
9+
10+
@pytest.fixture
11+
def runtime():
12+
with patch("uipath_mcp._cli._runtime._runtime.UiPath"):
13+
rt = UiPathMcpRuntime(
14+
server=MagicMock(),
15+
runtime_id="test-runtime-id",
16+
entrypoint="test-entrypoint",
17+
)
18+
rt._uipath = MagicMock()
19+
return rt
20+
21+
22+
@pytest.mark.asyncio
23+
async def test_folder_path_missing_raises_error(runtime):
24+
"""Error when UIPATH_FOLDER_PATH is not set at all."""
25+
with (
26+
patch.object(runtime, "_validate_auth"),
27+
patch.dict("os.environ", {}, clear=True),
28+
pytest.raises(UiPathMcpRuntimeError) as exc_info,
29+
):
30+
await runtime._run_server()
31+
32+
assert "Please set the UIPATH_FOLDER_PATH" in str(exc_info.value)
33+
34+
35+
@pytest.mark.asyncio
36+
async def test_folder_path_not_found_raises_error(runtime):
37+
"""Error when UIPATH_FOLDER_PATH is set but the folder doesn't exist."""
38+
runtime._uipath.folders.retrieve_key.return_value = None
39+
40+
with (
41+
patch.object(runtime, "_validate_auth"),
42+
patch.dict("os.environ", {ENV_FOLDER_PATH: "NonExistent/Folder"}, clear=True),
43+
pytest.raises(UiPathMcpRuntimeError) as exc_info,
44+
):
45+
await runtime._run_server()
46+
47+
error_msg = str(exc_info.value)
48+
assert "NonExistent/Folder" in error_msg
49+
assert "not found" in error_msg.lower()

uv.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)