Skip to content

Commit 16001ec

Browse files
authored
Merge pull request #44 from UiPath/fix/none-input
fix: None input value
2 parents ab30aa8 + fe29268 commit 16001ec

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath-runtime"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/runtime/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class UiPathRuntimeContext(BaseModel):
4949

5050
model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
5151

52-
def get_input(self) -> dict[str, Any]:
52+
def get_input(self) -> dict[str, Any] | None:
5353
"""Get parsed input data.
5454
5555
Priority:
@@ -107,10 +107,10 @@ def _read_input_from_file(self, file_path: str) -> dict[str, Any]:
107107
category=UiPathErrorCategory.SYSTEM,
108108
) from e
109109

110-
def _parse_input_string(self, input_str: str | None) -> dict[str, Any]:
110+
def _parse_input_string(self, input_str: str | None) -> dict[str, Any] | None:
111111
"""Parse input from JSON string."""
112112
if not input_str or input_str.strip() == "":
113-
return {}
113+
return None
114114

115115
try:
116116
parsed = json.loads(input_str)

tests/test_context.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,30 @@ def test_result_file_written_on_fault_contains_error_contract(tmp_path: Path) ->
146146
assert error["code"] == "ERROR_RuntimeError"
147147
assert error["title"] == "Runtime error: RuntimeError"
148148
assert "Stream blew up" in error["detail"]
149+
150+
151+
def test_parse_input_string_returns_none_for_empty_string() -> None:
152+
"""Test that empty input string returns None, not empty dict."""
153+
ctx = UiPathRuntimeContext(input="")
154+
155+
result = ctx.get_input()
156+
157+
assert result is None
158+
159+
160+
def test_parse_input_string_returns_none_for_whitespace_only() -> None:
161+
"""Test that whitespace-only input string returns None, not empty dict."""
162+
ctx = UiPathRuntimeContext(input=" ")
163+
164+
result = ctx.get_input()
165+
166+
assert result is None
167+
168+
169+
def test_parse_input_string_returns_none_for_none() -> None:
170+
"""Test that None input returns None."""
171+
ctx = UiPathRuntimeContext(input=None)
172+
173+
result = ctx.get_input()
174+
175+
assert result is None

uv.lock

Lines changed: 1 addition & 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)