Skip to content

fix(property): do not mutate schemas when normalizing union types - #258

Open
fede-kamel wants to merge 1 commit into
oracle:mainfrom
fede-kamel:fix/property-union-normalization
Open

fix(property): do not mutate schemas when normalizing union types#258
fede-kamel wants to merge 1 commit into
oracle:mainfrom
fede-kamel:fix/property-union-normalization

Conversation

@fede-kamel

Copy link
Copy Markdown
Member

Fixes #254.

Root cause

_normalize_json_schema_union_types in property.py used schema.get("anyOf", []) as the accumulator of normalized types and appended the entries of the type list to it. When the schema already had an anyOf list, the appends went into the caller's list, so every json_schemas_have_same_type / json_schema_is_castable_to / value_is_of_compatible_type call on such a schema grew its anyOf. These functions run during Flow and DataFlowEdge validation, so a Property.json_schema could change as a side effect of building a flow.

Changes

  • property.py: accumulate the normalized types in a copy of the anyOf list.
  • tests/test_properties.py: regression test comparing a schema that combines a type list with anyOf several times and asserting both schemas are unchanged. Fails on main, passes with the fix.
  • Changelog entry under Bug fixes.

Verification

  • pytest tests/test_properties.py: 177 passed, 2 skipped. Full suite: 1180 passed, 586 skipped (SKIP_LLM_TESTS=1).
  • Public CI steps (black, isort, flake8 + copyright, bandit, mypy, tests/run_tests.sh) reproduced locally on Python 3.10 through 3.14.

_normalize_json_schema_union_types reused the schema's own anyOf list
as the accumulator of normalized types, so comparing or checking the
castability of a schema combining a `type` list with `anyOf` appended
the entries of `type` to the schema's anyOf. The normalized types are
now accumulated in a copy.

Signed-off-by: Federico Kamelhar <federico.kamelhar@oracle.com>
@fede-kamel
fede-kamel requested a review from a team September 11, 2026 16:22
@oracle-contributor-agreement oracle-contributor-agreement Bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Property type comparison mutates schemas that combine a type list with anyOf

1 participant