diff --git a/pyproject.toml b/pyproject.toml index d65b047..0c8c284 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath-runtime" -version = "0.2.1" +version = "0.2.2" description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem" readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.11" diff --git a/src/uipath/runtime/context.py b/src/uipath/runtime/context.py index 64accab..87fe29c 100644 --- a/src/uipath/runtime/context.py +++ b/src/uipath/runtime/context.py @@ -49,7 +49,7 @@ class UiPathRuntimeContext(BaseModel): model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow") - def get_input(self) -> dict[str, Any]: + def get_input(self) -> dict[str, Any] | None: """Get parsed input data. Priority: @@ -107,10 +107,10 @@ def _read_input_from_file(self, file_path: str) -> dict[str, Any]: category=UiPathErrorCategory.SYSTEM, ) from e - def _parse_input_string(self, input_str: str | None) -> dict[str, Any]: + def _parse_input_string(self, input_str: str | None) -> dict[str, Any] | None: """Parse input from JSON string.""" if not input_str or input_str.strip() == "": - return {} + return None try: parsed = json.loads(input_str) diff --git a/tests/test_context.py b/tests/test_context.py index fac501f..9f744e9 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -146,3 +146,30 @@ def test_result_file_written_on_fault_contains_error_contract(tmp_path: Path) -> assert error["code"] == "ERROR_RuntimeError" assert error["title"] == "Runtime error: RuntimeError" assert "Stream blew up" in error["detail"] + + +def test_parse_input_string_returns_none_for_empty_string() -> None: + """Test that empty input string returns None, not empty dict.""" + ctx = UiPathRuntimeContext(input="") + + result = ctx.get_input() + + assert result is None + + +def test_parse_input_string_returns_none_for_whitespace_only() -> None: + """Test that whitespace-only input string returns None, not empty dict.""" + ctx = UiPathRuntimeContext(input=" ") + + result = ctx.get_input() + + assert result is None + + +def test_parse_input_string_returns_none_for_none() -> None: + """Test that None input returns None.""" + ctx = UiPathRuntimeContext(input=None) + + result = ctx.get_input() + + assert result is None diff --git a/uv.lock b/uv.lock index c75b711..dd6dfa4 100644 --- a/uv.lock +++ b/uv.lock @@ -1005,7 +1005,7 @@ wheels = [ [[package]] name = "uipath-runtime" -version = "0.2.1" +version = "0.2.2" source = { editable = "." } dependencies = [ { name = "uipath-core" },