Skip to content

Commit 6b305b9

Browse files
authored
Merge pull request #80 from UiPath/fix/faulted-trigger-error-exc-val
fix: pass exception instance instead of type in faulted trigger error handler
2 parents 9983daf + 6bd31b8 commit 6b305b9

File tree

5 files changed

+38
-3
lines changed

5 files changed

+38
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ wheels/
2828

2929
.cache/*
3030
.cache
31+
32+
.claude

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.7.0"
3+
version = "0.7.1"
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
206206
match exc_val:
207207
case UiPathFaultedTriggerError():
208208
error_info = UiPathRuntimeError.from_resume_trigger_error(
209-
exc_type
209+
exc_val
210210
).error_info
211211
case UiPathBaseRuntimeError():
212212
error_info = exc_val.error_info

tests/test_context.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Any
44

55
import pytest
6+
from uipath.core.errors import ErrorCategory, UiPathFaultedTriggerError
67

78
from uipath.runtime.context import UiPathRuntimeContext
89
from uipath.runtime.errors import (
@@ -236,6 +237,38 @@ def test_from_config_loads_runtime_and_fps_properties(tmp_path: Path) -> None:
236237
assert ctx.mcp_server_slug == "test-server-slug"
237238

238239

240+
def test_result_file_written_on_faulted_trigger_error(tmp_path: Path) -> None:
241+
runtime_dir = tmp_path / "runtime"
242+
ctx = UiPathRuntimeContext(
243+
job_id="job-trigger-test",
244+
runtime_dir=str(runtime_dir),
245+
result_file="result.json",
246+
)
247+
248+
trigger_error = UiPathFaultedTriggerError(
249+
ErrorCategory.SYSTEM, "Failed to create HITL action", "validation error"
250+
)
251+
trigger_error.category = ErrorCategory.SYSTEM
252+
trigger_error.message = "Failed to create HITL action"
253+
254+
with pytest.raises(UiPathFaultedTriggerError):
255+
with ctx:
256+
raise trigger_error
257+
258+
result_path = Path(ctx.resolved_result_file_path)
259+
assert result_path.exists()
260+
261+
content = json.loads(result_path.read_text())
262+
assert content["status"] == UiPathRuntimeStatus.FAULTED.value
263+
assert "error" in content
264+
265+
error = content["error"]
266+
assert error["code"] == f"Python.{UiPathErrorCode.RESUME_TRIGGER_ERROR.value}"
267+
assert error["title"] == "Resume trigger error"
268+
assert "Failed to create HITL action" in error["detail"]
269+
assert error["category"] == ErrorCategory.SYSTEM.value
270+
271+
239272
def test_string_output_wrapped_in_dict() -> None:
240273
"""Test that string output is wrapped in a dict with key 'output'."""
241274
result = UiPathRuntimeResult(

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)