You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ingestion): build_patch crashes on EntityReferenceList fields in array_entity_fields #32008
_sort_array_entity_fields in patch_request.py crashes with AttributeError: 'list' object has no attribute 'root' when any EntityReferenceList-typed field (e.g. domains, dataProducts) is passed in array_entity_fields.
Two issues in the same function:
Iterating a RootModel yields tuples, not items — pydantic v2 RootModel iteration yields (key, value) tuples, so _get_attribute_name and __dict__ access both fail.
setattr with a plain list breaks serialization — replacing a RootModel field with a bare list causes subsequent model_dump_json calls to crash because pydantic expects the RootModel wrapper.
This affects anyone calling metadata.patch() with array_entity_fields containing EntityReferenceList-typed fields (e.g. dataProducts, domains, owners, reviewers).
Reproduction
frommetadata.generated.schema.entity.data.tableimportTablefrommetadata.generated.schema.type.entityReferenceimportEntityReferencefrommetadata.generated.schema.type.entityReferenceListimportEntityReferenceListfrommetadata.ingestion.models.patch_requestimportbuild_patchimportuuidsource=Table(id=str(uuid.uuid4()), name='t', columns=[], fullyQualifiedName='svc.db.schema.t')
source.dataProducts=EntityReferenceList(root=[])
dest=source.model_copy(deep=True)
dest.dataProducts=EntityReferenceList(root=[EntityReference(id=str(uuid.uuid4()), type='dataProduct', name='dp1')])
build_patch(source=source, destination=dest, array_entity_fields=['dataProducts'])
# RuntimeError: Failed to build patch. Error: 'list' object has no attribute 'root'
Fix
In _sort_array_entity_fields:
Extract .root before iterating RootModel fields
Re-wrap via model_copy(update={"root": ...}) instead of setting a bare list
Activity