Skip to content

fix: unwrap PEP 604 union types (X | None) in _unwrap_optional#800

Merged
radu-mocanu merged 1 commit intomainfrom
fix/unwrap-union-type-python313
Apr 23, 2026
Merged

fix: unwrap PEP 604 union types (X | None) in _unwrap_optional#800
radu-mocanu merged 1 commit intomainfrom
fix/unwrap-union-type-python313

Conversation

@radu-mocanu
Copy link
Copy Markdown
Collaborator

@radu-mocanu radu-mocanu commented Apr 23, 2026

Summary

  • fix job attachment detection failing on Python 3.10-3.13 when agent input fields use X | None syntax
  • _unwrap_optional now handles both typing.Union (Optional[X]) and types.UnionType (X | None)

Why

on Python 3.10-3.13, get_origin(X | None) returns types.UnionType instead of typing.Union. the _unwrap_optional check was only testing for typing.Union, so Attachment | None field annotations were never unwrapped to Attachment, causing get_job_attachment_paths to return no paths and job_attachments to stay empty. Python 3.14 changed get_origin to return typing.Union for both forms, masking the bug locally.

Development Package

  • Use uipath pack --nolock to get the latest dev build from this PR (requires version range).
  • Add this package as a dependency in your pyproject.toml:
[project]
dependencies = [
  # Exact version:
  "uipath-langchain==0.10.1.dev1008004366",

  # Any version from PR
  "uipath-langchain>=0.10.1.dev1008000000,<0.10.1.dev1008010000"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-langchain = { index = "testpypi" }

[tool.uv]
override-dependencies = [
    "uipath-langchain>=0.10.1.dev1008000000,<0.10.1.dev1008010000",
]

@radu-mocanu radu-mocanu force-pushed the fix/unwrap-union-type-python313 branch from b99805d to aa9a294 Compare April 23, 2026 18:02
@radu-mocanu radu-mocanu merged commit 280fc1a into main Apr 23, 2026
44 of 45 checks passed
@radu-mocanu radu-mocanu deleted the fix/unwrap-union-type-python313 branch April 23, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants