Repository navigation
Fixes #34448: hydrate FQN→id and compare by FQN for relationship-type inverse/replacedBy references - #34507
Conversation
… inverse/replacedBy references
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
✅ Playwright Results — workflow succeededValidated commit ✅ 4684 passed · ❌ 0 failed · 🟡 2 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 1h 40m 22s ⏱️ Max setup 4m 28s · max shard execution 19m 18s · max shard-job elapsed before upload 23m 14s · reporting 17s 🌐 222.46 requests/attempt · 2.20 app boots/UI scenario · 34.72% common-shard skew Optimization targets still in progress:
🟡 2 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
Detail bug report: View on Detail
Describe your changes:
Fixes #34448
The public REST API (
RelationshipTypeMapper) buildsinverse/replacedBy/propertyChain/disjointWithreferences with onlytype+fullyQualifiedNameset (id == null), because clients supply FQN strings, not ids. The seed/legacy path (LegacyRelationshipTypeMapper) resolves FQNs to real ids via repository lookups; the public API path never did. As a result:RelationshipTypeValidator.validateInversecomparedgetId()only, so a SYMMETRIC type withinverseset to its own FQN was falsely rejected ("A symmetric relationship must be its own inverse").RelationshipTypeValidator.validateReplacementcomparedgetId()only, soreplacedByset to the type's own FQN bypassed the self-replacement guard.GlossaryOntologyExporter.predicateIrimatched bygetId()only, so a relevant deprecated type with a null-idreplacedBythrewIllegalArgumentException("Relationship type 'null' is not registered")at export time.I worked on fixing these because the bug, introduced in 7b1bc6b (PR #28042), made the public REST API unable to reliably set
inverse/replacedBy— valid requests were rejected and invalid configurations were stored, and glossary RDF export could fail at runtime.Type of change:
High-level design:
The fix has three layers:
Root-cause hydration —
RelationshipTypeRepository.preparenow calls a newhydrateReferencesthat resolves FQN→id forinverse,replacedBy,propertyChain, anddisjointWithbefore validation. Self-references (reference FQN == entity FQN) reuse the entity's own id; other references resolve viafindByNameOrNull(fqn, Include.ALL). This covers POST, PUT (create + update), and PATCH (all callprepareInternal). This is the layer that fixes the RDF exporter throw, since stored rows now carry real ids.Defense-in-depth validator checks —
RelationshipTypeValidator.validateInverseandvalidateReplacementnow compare by FQN in addition to id via a sharedisSelfReferencehelper (id match OR FQN match). This keeps the invariant even if a reference bypassesprepare(e.g., the updater re-validates on characteristics change, or PATCH loads pre-fix stored rows with null-id references).Defense-in-depth exporter lookup —
GlossaryOntologyExporter.predicateIrinow matches by id OR FQN. This protects the exporter against relationship types stored before the fix that carry null-id references (no backfill migration is included in this change).Alternatives considered: a minimal fix confined to the validators (FQN comparison only) would fix both validation symptoms but not the exporter throw, which requires stored references to carry real ids. The hydration fix is needed regardless, so the validator/exporter FQN-fallback is layered on top as defense in depth.
Tests:
Use cases covered
inverseset to the type's own FQN is accepted (was falsely rejected).replacedByset to the type's own FQN is rejected (was falsely accepted).inverseFQN is still rejected; non-selfreplacedByFQN is still accepted.inversestill works viaapplyDefaults.replacedBy/inverse/propertyChain/disjointWithreferences by FQN and does not throw for relevant deprecated types with null-id references.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/ontology/RelationshipTypeValidatorTest.java(+7 cases: the two bug repros, their FQN complements, a null-inverse guard, a full-reference (id+fqn) legacy-path guard, and an id-path guard for the rewrittenvalidateReplacement).A symmetric relationship must be its own inverse) and symptom 2 (Expected BadRequestException to be thrown, but nothing was thrown) exactly as described in the issue.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.RelationshipTypeResourceITdoes not setinverse/replacedBy; extending it to cover the SYMMETRIC-self-inverse and self-replacement end-to-end paths is the right follow-up, but those integration tests require the Docker-based MySQL/Elasticsearch stack and could not be executed in this session (Docker Hub unauthenticated pull rate limit blocked themysql:8.3.0Testcontainers image). The unit-test layer covers the same validator code paths; the end-to-end HTTP + persistence path (PUT/PATCH create-or-update) is pending an environment with Docker Hub access.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
mvn spotless:applyandmvn spotless:checkonopenmetadata-service— pass (no formatting diff).mvn compile -pl openmetadata-service— pass.RelationshipTypeValidatorTest— 16/16 pass (9 pre-existing + 7 new).RelationshipTypeGraphValidatorTest— 4/4 pass (no regression in graph validation).org.openmetadata.service.ontology.*Test,org.openmetadata.service.rdf.*Test) — 655/655 pass.RelationshipTypeValidatorTest— the two bug-repro cases failed exactly as the issue describes, confirming the tests reproduce the defect; restored the fix and all 16 pass.mvn clean install -pl :openmetadata-integration-tests -am— 11 reactor modules SUCCESS). The Elasticsearch image pulled successfully; the MySQL image could not be pulled due to Docker Hub HTTP 429 (ratelimit-remaining: 0;w=3600per IP), soRelationshipTypeResourceIT,RelationshipTypeContradictionIT, andRdfResourceITcould not be executed. The blocking output:UI screen recording / screenshots:
Not applicable.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Automatic Fixes PRs can be configured here.