Skip to content

Commit 2b0e1d5

Browse files
committed
fix(functions): serialize function output by its field aliases
1 parent 7181c27 commit 2b0e1d5

4 files changed

Lines changed: 40 additions & 3 deletions

File tree

‎packages/uipath/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"
3-
version = "2.14.32"
3+
version = "2.14.33"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

‎packages/uipath/src/uipath/functions/type_conversion.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def convert_from_class(obj: Any) -> dict[str, Any]:
9292

9393
# Pydantic models
9494
if isinstance(obj, BaseModel):
95-
return obj.model_dump()
95+
return obj.model_dump(by_alias=True)
9696

9797
# Dataclasses
9898
if is_dataclass(obj) and not isinstance(obj, type):
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""A function's output is serialized under the keys its output schema declares."""
2+
3+
import uuid
4+
5+
from pydantic import BaseModel
6+
7+
from uipath.functions.type_conversion import convert_from_class
8+
from uipath.platform.attachments import Attachment
9+
10+
11+
class Output(BaseModel):
12+
file: Attachment
13+
14+
15+
def test_aliased_fields_are_serialized_by_alias():
16+
attachment_id = uuid.uuid4()
17+
output = Output(
18+
file=Attachment(
19+
id=attachment_id, full_name="report.md", mime_type="text/markdown"
20+
)
21+
)
22+
23+
assert convert_from_class(output) == {
24+
"file": {
25+
"ID": attachment_id,
26+
"FullName": "report.md",
27+
"MimeType": "text/markdown",
28+
"Metadata": None,
29+
}
30+
}
31+
32+
33+
def test_models_without_aliases_are_unchanged():
34+
class Plain(BaseModel):
35+
summary: str
36+
37+
assert convert_from_class(Plain(summary="ok")) == {"summary": "ok"}

‎packages/uipath/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)