Skip to content

Fixes #34448: hydrate FQN→id and compare by FQN for relationship-type inverse/replacedBy references - #34507

Merged
harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-34448-hydrate-fqn-id-and-compare-by-fqn-for-161b3d
Oct 6, 2026
Merged

harshach merged 1 commit into
mainfrom
detail/bug-fix/fixes-34448-hydrate-fqn-id-and-compare-by-fqn-for-161b3d

Conversation

@detail-app

@detail-app detail-app Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #34448

The public REST API (RelationshipTypeMapper) builds inverse/replacedBy/propertyChain/disjointWith references with only type + fullyQualifiedName set (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.validateInverse compared getId() only, so a SYMMETRIC type with inverse set to its own FQN was falsely rejected ("A symmetric relationship must be its own inverse").
  • RelationshipTypeValidator.validateReplacement compared getId() only, so replacedBy set to the type's own FQN bypassed the self-replacement guard.
  • GlossaryOntologyExporter.predicateIri matched by getId() only, so a relevant deprecated type with a null-id replacedBy threw IllegalArgumentException("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:

  • Bug fix

High-level design:

The fix has three layers:

  1. Root-cause hydration — RelationshipTypeRepository.prepare now calls a new hydrateReferences that resolves FQN→id for inverse, replacedBy, propertyChain, and disjointWith before validation. Self-references (reference FQN == entity FQN) reuse the entity's own id; other references resolve via findByNameOrNull(fqn, Include.ALL). This covers POST, PUT (create + update), and PATCH (all call prepareInternal). This is the layer that fixes the RDF exporter throw, since stored rows now carry real ids.

  2. Defense-in-depth validator checks — RelationshipTypeValidator.validateInverse and validateReplacement now compare by FQN in addition to id via a shared isSelfReference helper (id match OR FQN match). This keeps the invariant even if a reference bypasses prepare (e.g., the updater re-validates on characteristics change, or PATCH loads pre-fix stored rows with null-id references).

  3. Defense-in-depth exporter lookup — GlossaryOntologyExporter.predicateIri now 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

  • Creating a SYMMETRIC relationship type with inverse set to the type's own FQN is accepted (was falsely rejected).
  • Creating a relationship type with replacedBy set to the type's own FQN is rejected (was falsely accepted).
  • SYMMETRIC with a non-self inverse FQN is still rejected; non-self replacedBy FQN is still accepted.
  • SYMMETRIC with omitted inverse still works via applyDefaults.
  • RDF glossary export resolves replacedBy/inverse/propertyChain/disjointWith references by FQN and does not throw for relevant deprecated types with null-id references.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files updated: 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 rewritten validateReplacement).
  • The two exact bug repros were verified to fail against the pre-fix source (with the fix reverted) and pass after restoring it — they reproduce symptom 1 (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

  • I added integration tests in openmetadata-integration-tests/ for new/changed API endpoints.
  • Not added in this PR. The existing RelationshipTypeResourceIT does not set inverse/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 the mysql:8.3.0 Testcontainers 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

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • mvn spotless:apply and mvn spotless:check on openmetadata-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).
  • Full ontology + RDF unit-test sweep (org.openmetadata.service.ontology.*Test, org.openmetadata.service.rdf.*Test) — 655/655 pass.
  • Sanity check: temporarily reverted the three source files (keeping the new tests) and re-ran 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.
  • Integration test runtime builds cleanly (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=3600 per IP), so RelationshipTypeResourceIT, RelationshipTypeContradictionIT, and RdfResourceIT could not be executed. The blocking output:
    com.github.dockerjava.api.exception.DockerException: Status 429: {"message":"toomanyrequests: You have reached your unauthenticated pull rate limit. https://www.docker.com/increase-rate-limit"}
    org.testcontainers.containers.ContainerFetchException: Can't get Docker image: RemoteDockerImage(imageName=mysql:8.3.0, ...)
    java.lang.RuntimeException: TestSuiteBootstrap initialization failed
    
    These integration tests should be re-run once the Docker Hub rate-limit window refreshes; they exercise the end-to-end POST/PUT/PATCH + RDF export paths (G7–G12 in the test plan) that the unit tests don't reach.

UI screen recording / screenshots:

Not applicable.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. — N/A (no schema changes).
  • For UI changes: I attached a screen recording and/or screenshots above. — N/A.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

Automatic Fixes PRs can be configured here.

@detail-app
detail-app Bot requested a review from a team as a code owner October 2, 2026 05:08
@detail-app
detail-app Bot requested a review from harshach October 2, 2026 05:08
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit db9fe9a6ee40a344dade849a1db3009865ea7a40 in Playwright run 36970379623, attempt 1.

✅ 4684 passed · ❌ 0 failed · 🟡 2 flaky · ⏭️ 1 skipped · 🧰 0 lifecycle flaky

Performance

Blocking 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:

  • Common shard skew was 34.72% (convergence target: at most 15%).
  • Browser traffic was 222.46 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.2 per UI scenario (10956 boots / 4975 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard advanced-search-01 65 0 0 0 0 0
✅ Shard advanced-search-02 65 0 0 0 0 0
✅ Shard chromium-01 148 0 0 0 0 0
🟡 Shard chromium-02 127 0 1 0 0 0
✅ Shard chromium-03 145 0 0 0 0 0
✅ Shard chromium-04 147 0 0 0 0 0
✅ Shard chromium-05 177 0 0 0 0 0
✅ Shard chromium-06 186 0 0 0 0 0
✅ Shard chromium-07 131 0 0 0 0 0
✅ Shard chromium-08 173 0 0 0 0 0
✅ Shard chromium-09 142 0 0 0 0 0
✅ Shard chromium-10 171 0 0 0 0 0
✅ Shard chromium-11 137 0 0 0 0 0
✅ Shard chromium-12 227 0 0 0 0 0
✅ Shard chromium-13 142 0 0 0 0 0
✅ Shard chromium-14 164 0 0 0 0 0
✅ Shard chromium-15 179 0 0 0 0 0
✅ Shard chromium-16 162 0 0 0 0 0
✅ Shard chromium-17 147 0 0 0 0 0
🟡 Shard chromium-18 158 0 1 0 0 0
✅ Shard chromium-19 164 0 0 0 0 0
✅ Shard chromium-20 146 0 0 0 0 0
✅ Shard chromium-21 136 0 0 0 0 0
✅ Shard chromium-22 156 0 0 0 0 0
✅ Shard chromium-23 156 0 0 1 0 0
✅ Shard chromium-24 177 0 0 0 0 0
✅ Shard chromium-25 156 0 0 0 0 0
✅ Shard chromium-26 153 0 0 0 0 0
✅ Shard data-asset-rules-01 65 0 0 0 0 0
✅ Shard domain-isolation-01 16 0 0 0 0 0
✅ Shard global-state-01 34 0 0 0 0 0
✅ Shard import-export-01 84 0 0 0 0 0
✅ Shard import-export-02 68 0 0 0 0 0
✅ Shard ingestion-01 41 0 0 0 0 0
✅ Shard ingestion-02 52 0 0 0 0 0
✅ Shard reindex-01 41 0 0 0 0 0
✅ Shard search-01 17 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0
🟡 2 flaky test(s) (passed on retry)
  • Pages/CustomProperties.spec.ts › Number CP between operator sends gte/lte bounds (Issue #27482) (shard chromium-02, 1 retry)
  • Features/Glossary/GlossaryAdvancedOperations.spec.ts › should remove reviewer from term (shard chromium-18, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

@detail-app detail-app Bot added the safe to test Add this label to run secure Github workflows on PRs label Oct 2, 2026
@harshach
harshach added this pull request to the merge queue Oct 6, 2026
Merged via the queue into main with commit f3d94b5 Oct 6, 2026
233 of 245 checks passed
@harshach
harshach deleted the detail/bug-fix/fixes-34448-hydrate-fqn-id-and-compare-by-fqn-for-161b3d branch October 6, 2026 14:36

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] Ontology API: Relationship type create/update mishandles inverse and replacedBy references supplied by FQN

1 participant