-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix #27107: soft-deleted users still appear in Experts/Reviewers across all entities #27120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 16 commits
89122f6
f56057c
3264fb3
841775b
d4743a1
05b41cb
1a1888a
0c45006
639c950
97f328a
d9aa379
00e7896
37a014a
47def38
4af35c3
b3d7482
d5446b1
736b773
007976e
21c8e64
f4a875e
5e77478
8b443b1
85911a3
6807212
70a4b67
344bc44
7217773
135be1c
607743b
9e31dbc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.UUID; | ||
| import java.util.function.Function; | ||
| import java.util.stream.Collectors; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.jdbi.v3.sqlobject.transaction.Transaction; | ||
|
|
@@ -47,6 +48,7 @@ | |
| import org.openmetadata.schema.utils.JsonUtils; | ||
| import org.openmetadata.schema.utils.ResultList; | ||
| import org.openmetadata.service.Entity; | ||
| import org.openmetadata.service.exception.EntityNotFoundException; | ||
| import org.openmetadata.service.resources.domains.DomainResource; | ||
| import org.openmetadata.service.resources.feeds.MessageParser.EntityLink; | ||
| import org.openmetadata.service.search.DefaultInheritedFieldEntitySearch; | ||
|
|
@@ -185,9 +187,16 @@ public void setInheritedFields(Domain domain, Fields fields) { | |
| // domain | ||
| EntityReference parentRef = domain.getParent() != null ? domain.getParent() : getParent(domain); | ||
| if (parentRef != null) { | ||
| Domain parent = Entity.getEntity(DOMAIN, parentRef.getId(), "owners,experts", ALL); | ||
| inheritOwners(domain, fields, parent); | ||
| inheritExperts(domain, fields, parent); | ||
| try { | ||
| Domain parent = Entity.getEntity(DOMAIN, parentRef.getId(), "owners,experts", NON_DELETED); | ||
| inheritOwners(domain, fields, parent); | ||
| inheritExperts(domain, fields, parent); | ||
| } catch (EntityNotFoundException ex) { | ||
| LOG.debug( | ||
| "Skipping inherited fields from soft-deleted or missing parent domain {} for domain {}", | ||
| parentRef.getId(), | ||
| domain.getId()); | ||
| } | ||
| } | ||
|
Comment on lines
+184
to
192
|
||
| } | ||
|
|
||
|
|
@@ -580,22 +589,28 @@ private Map<UUID, List<EntityReference>> batchFetchExperts(List<Domain> domains) | |
| return expertsMap; | ||
| } | ||
|
|
||
| // Initialize empty lists for all domains | ||
| domains.forEach(domain -> expertsMap.put(domain.getId(), new ArrayList<>())); | ||
|
|
||
| // Single batch query to get all expert relationships | ||
| var records = | ||
| daoCollection | ||
| .relationshipDAO() | ||
| .findToBatch(entityListToStrings(domains), Relationship.EXPERT.ordinal(), Entity.USER); | ||
|
|
||
| // Group experts by domain ID | ||
| List<UUID> expertIds = | ||
| records.stream().map(r -> UUID.fromString(r.getToId())).distinct().toList(); | ||
| Map<UUID, EntityReference> expertRefsById = | ||
| Entity.getEntityReferencesByIdsRespectingInclude( | ||
| Entity.USER, expertIds, Include.NON_DELETED) | ||
| .stream() | ||
| .collect(Collectors.toMap(EntityReference::getId, Function.identity(), (a, b) -> a)); | ||
|
|
||
| records.forEach( | ||
| record -> { | ||
| var domainId = UUID.fromString(record.getFromId()); | ||
| var expertRef = | ||
| getEntityReferenceById(Entity.USER, UUID.fromString(record.getToId()), NON_DELETED); | ||
| expertsMap.get(domainId).add(expertRef); | ||
| var expertRef = expertRefsById.get(UUID.fromString(record.getToId())); | ||
| if (expertRef != null) { | ||
| expertsMap.get(domainId).add(expertRef); | ||
| } | ||
| }); | ||
|
|
||
| return expertsMap; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paging loop has no hard stop / cursor-repeat protection. If paging ever returns a non-null
afterthat doesn’t advance (or cycles), this test can hang indefinitely in CI. Consider adding a max-iterations bound and/or tracking previously seenaftercursors to fail fast with a clear assertion.