Repository navigation
Conversation
transform_nullable_types returned only the non-null branch of a two-entry anyOf, so keys beside the anyOf were lost. That dropped the description and title of every Optional field in the generated schema. transform_references had the same loss for keys beside a $ref. Merge those sibling keys back into the result, with the siblings winning over the branch or definition. A default of None is still dropped, because the null branch it described is gone. A non-null default is kept.
|
There was a problem hiding this comment.
🟡 Changes recommended
An active moderate issue remains because sibling schema values can retain unresolved nested references and omit their circular-reference status.
1 open issue
What changed in this PR
Preserves field metadata in runtime schemas used by uipath init when collapsing nullable types and resolving references.
Changes:
- Retains sibling keys, giving them precedence over branch or definition values.
- Drops null defaults while preserving non-null defaults.
- Adds six regression tests and updates the expected nullable-field title.
| File | Description |
|---|---|
tests/test_schema.py |
Tests metadata, defaults, precedence, and circular references. |
src/uipath/runtime/schema.py |
Preserves sibling keys during schema transformations. |
Review effort: Lite
| siblings = {k: v for k, v in schema.items() if k != "$ref"} | ||
|
|
||
| if ref_path in visited: | ||
| # Circular dependency detected | ||
| return { | ||
| "type": "object", | ||
| "description": f"Circular reference to {ref_path}", | ||
| **siblings, | ||
| }, True | ||
|
|
||
| visited.add(ref_path) |
There was a problem hiding this comment.
Not changing this. Pydantic emits only description, title, default, examples and deprecated beside $ref (checked on pydantic 2.14.4), so no sibling holds a schema that needs resolving. Recursing into them would also rewrite default and examples payloads, which are data.
On origin/main siblings were dropped entirely, so this PR adds no unresolved ref that was resolved before.
nikhil-maryala
left a comment
There was a problem hiding this comment.
Approve. No blocker. Small findings, none needed to merge.
Checked at 2b29a55:
- Siblings are kept correctly in both collapses. A sibling wins over the
$reftarget and over the non-null branch (src/uipath/runtime/schema.py:203, :237). This is right: the field-level description and title beat the class docstring. - Null semantics are as before: the collapse still drops the null branch (schema.py:231-237). The PR only drops
default: null, which is consistent with that (schema.py:235-236). - A non-null default is kept. Circular refs also keep siblings (schema.py:179, :186).
Small findings:
- schema.py:179/203, Copilot comment: siblings are not passed through
transform_references. Real in theory. Pydantic emits only description, title and default beside$ref. Adefaultis data, so recursing into it would be wrong. Apropertiessibling with a$refstays unresolved. Low. A comment or a note is enough. - schema.py:237:
non_null_typeis returned without recursion (the code was like this before the PR). A nestedanyOfwith null inside anOptional[Model]field is not collapsed. Add a test with an inner nullable field. - schema.py:228: only
anyOfwith exactly 2 branches collapses. Three or more branches keep null and are not tested. - Tests: no test for
$refsiblings that settypeortitleagainst the target. Tests for a collapse inside a list (items) are also missing. - tests/test_schema.py:286: output schemas now carry
titleon plain optional fields. This is a visible change for consumers. It looks intended.
Not verified: I did not run the tests, because pydantic is not installed in this sandbox and I did not install from the network. CI was not checked.




Summary
uipath initwrites a schema for each entrypoint input and output. For a field typedOptional[X], pydantic emits ananyOfwith anullbranch and putsdescriptionandtitlebeside it.transform_nullable_typesreturned only the non-null branch, so the field lost its description and title inentry-points.json.transform_referencesdid the same to keys that sit beside a$ref.This change merges those sibling keys back into the result. The siblings win over the branch or definition, so a field description beats the description of the referenced class. A
defaultofNoneis still dropped, because the null branch it described is gone. A non-null default such as0.5is kept.Bounds such as
geandlealready survived, because pydantic puts them inside the non-null branch. The description and title were the missing parts.Not in this change
Keeping
nullon outputs and on required nullable inputs is a separate step and is not touched here.Tests
tests/test_schema.pyadds six tests.Optional[float] = Field(None, ge=0, le=1, description="d")keeps its description, title and bounds, and has nodefault.float | None = Field(0.5, ...)keepsdefault: 0.5.$refsurvive resolution.$refsurvive.The existing combined test now expects the
titleontest_model_property, which is the intended new output.Verification
uv run pytesttests/test_schema.pyuv run ruff check .,uv run ruff format --check .,uv run mypy --config-file pyproject.toml .Optional[float] = Field(None, ge=0, le=1, description="d"), install this branch editable and runuipath initentry-points.jsoninputscorehasmaximum,minimum,type,descriptionandtitle, and nodefault. With releaseduipath-runtime0.13.8 the description and title are missing.lint,test,commit-lint)🔥 Critical layer: Real run. It is the only row that goes through
uipath initand the writtenentry-points.json.Coverage caveat: the unit tests ran on Python 3.11 and the real run on Python 3.12, both on macOS. CI also covers 3.13 and Windows. The golden files in the packages that depend on this function will gain a
titleon formerly nullable fields, and those packages refresh them after a release.PR description test plan: ✅ present