Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions src/uipath/runtime/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 27 additions & 0 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.