fix(context-center): tolerate related entities whose type has no repository in the list path - #31033
Conversation
…sitory in the list path The Context Center / Knowledge Center list endpoint (GET /v1/contextCenter/pages, formerly /v1/knowledgeCenter) with fields=relatedEntities fails for the whole page when a single page has a related-entity relationship row whose type has no entity repository — for example a search-index-only pseudo-type such as tableColumn. The bulk setFields path groups the HAS relationship rows by type and resolves each type via Entity.getEntityReferencesByIds, which calls Entity.getEntityRepository and throws: EntityNotFoundException: Entity repository for tableColumn not found. Is the ENTITY_TYPE_MAP initialized? One stray row turns the entire list response into a 404. The single-entity read path already tolerates this (EntityRelationshipRepository.getEntityReferences catches and skips unresolvable types); the hand-rolled bulk resolver in KnowledgePageRepository and its identical copy in ContextMemoryRepository did not. Skip relationship rows whose type has no repository (Entity.hasEntityRepository) at grouping time, mirroring the resilience of the single-entity path. This is self-maintaining (no hardcoded type list) and pagination-safe, since relatedEntities is a nested per-page field rather than the paginated collection itself. Adds an integration test that creates a page with a related entity of a type that has no repository and asserts the list path skips it instead of 404-ing, while still returning the resolvable related entities.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ ApprovedAdds resilience to the list path in KnowledgePageRepository and ContextMemoryRepository to skip related entity types without a repository, preventing 404 errors on list requests. No issues found. OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar | Powered by Gitar — free for open source |
There was a problem hiding this comment.
Pull request overview
This PR hardens the Context Center / Knowledge Center list path (GET /v1/contextCenter/pages?fields=relatedEntities) so it no longer fails the entire response when a page has a related-entity relationship pointing to an entity type without a registered repository (e.g., search-index-only pseudo-types like tableColumn). The change mirrors the single-entity read path’s behavior by skipping unresolvable relationship rows during bulk reference resolution.
Changes:
- Skip relationship rows for types that don’t have an entity repository during bulk related-entity resolution (prevents
EntityNotFoundException→ 404 for the whole list). - Apply the same resilience in both
KnowledgePageRepositoryandContextMemoryRepository. - Add an integration test that reproduces the failure and asserts the list response remains
200while skipping only the unresolvable related entity.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/KnowledgePageRepository.java | Filters out relationship rows whose fromEntity type has no repository before calling getEntityReferencesByIds, preventing list-wide failure. |
| openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ContextMemoryRepository.java | Applies the same repository-existence filter to the analogous bulk resolver to keep behavior consistent across the two implementations. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/KnowledgePageHierarchyIT.java | Adds an IT to ensure list requests with fields=relatedEntities tolerate a pseudo-type related entity and still return resolvable refs. |
What & Why
The Context Center / Knowledge Center list endpoint —
GET /v1/contextCenter/pages(formerly/v1/knowledgeCenter) — withfields=relatedEntitiesreturns a 404 for the entire page when any single page has a related-entity relationship row whose type has no entity repository, e.g. a search-index-only pseudo-type such astableColumn.Observed in the logs as:
Root cause
The bulk
setFieldspath resolves related entities inKnowledgePageRepository.resolveReferencesByType: it groups theHASrelationship rows byfromEntitytype and callsEntity.getEntityReferencesByIds(type, …)per type. For a type with no repository, that reachesEntity.getEntityRepository(type)and throwsEntityNotFoundException. A single stray relationship row therefore fails the whole list response.The single-entity read path does not have this problem:
EntityRelationshipRepository.getEntityReferencesalready catches and skips unresolvable types. The hand-rolled bulk resolver — and its byte-identical copy inContextMemoryRepository— omitted that resilience.How such a row exists:
KnowledgePageRepository.preparediscards the stripped return ofEntityUtil.populateEntityReferences, so a pseudo-type ref survives intostoreRelationshipsand is persisted as apage --HAS--> <pseudo-type>row. It is then unresolvable on read.Fix
Skip relationship rows whose type has no repository (
Entity.hasEntityRepository) at grouping time, in bothKnowledgePageRepositoryandContextMemoryRepository. This mirrors the single-entity path's resilience. It is:relatedEntitiesis a nested per-page field, not the paginated collection, so skipping an unresolvable ref does not affect page counts/offsets.Tests
Adds
KnowledgePageHierarchyIT#testListToleratesRelatedEntityWithoutRepository: creates a page whoserelatedEntitiesincludes both a resolvable ref and one of a type with no repository, then lists withfields=relatedEntitiesand asserts the list returns200with the unresolvable ref skipped and the resolvable ref still present. This test fails (404) without the fix.Manual reproduction
relatedEntitiesentry of{ "id": <uuid>, "type": "tableColumn" }.GET /v1/contextCenter/pages?fields=relatedEntities→ 404 with the error above (before the fix); 200 with the pseudo-type entry skipped (after the fix).