open-metadata / OpenMetadata

OpenMetadata is a unified metadata platform for data discovery, data observability, and data governance powered by a central metadata repository, in-depth column level lineage, and seamless team collaboration.
https://open-metadata.org
Apache License 2.0
5.62k stars 1.06k forks source link

bug: Table patch fails when multiple owners are defined #17840

Open mgorsk1 opened 2 months ago

mgorsk1 commented 2 months ago

Affected module Ingestion / Backend

Describe the bug When I try to patch the table entity and specify two owners in the patch request, the patch will fail with error (backend logs):

ERROR [2024-09-14 05:35:49,046] [dw-114 - PATCH /api/v1/tables/2d28de1a-0ea9-4759-b113-3c6a0bab6e72] o.o.s.r.d.TableResource - Got exception: [NullPointerException] / message [Cannot invoke "java.lang.Comparable.compareTo(Object)" because the return value of "java.util.function.Function.apply(Object)" is null] / related resource location: [org.openmetadata.service.resources.databases.TableResource.patch](TableResource.java:420)

To Reproduce

from metadata.generated.schema.entity.data.table import Table
from metadata.generated.schema.type.entityReference import EntityReference
from metadata.generated.schema.type.entityReferenceList import EntityReferenceList
from metadata.generated.schema.entity.teams.user import User

t = c.get_by_name(Table, "register-test-db-2.hive.register-test-db-2-udemy.raw_data_1")
u1 = c.get_by_name(User, "mariusz.gorski")
u2 = c.get_by_name(User, "tony.soprano")

owners2 = EntityReferenceList([EntityReference(id=u1.id.root, type="user"), EntityReference(id=u2.id.root, type="user")])

c.patch_owner(Table, t, owners2, force=True)  # fails

Expected behavior Both owners assigned as owners of a table.

Version:

Additional context Add any other context about the problem here.

harshach commented 2 months ago

You cannot do patch like that. Its needs a fresh copy from last call. Try doing a get and before the second patch call

mgorsk1 commented 2 months ago

I agree and I should have been more precise @harshach, to reproduce you should only run the line with # fails comment. I have amended the original issue not to create confusion. The problem remains and this issue is still valid after updating the code for reproducing.

I found that adding name property to EntityReference solves it but it might be some bug server side that it's required at all to work.