Skip to content

[2.1] Fixes #39764: make relationship types from a 2.0 upgrade valid in 2.1 (#39765) - #39882

Merged
sonika-shah merged 2 commits into
2.1from
fix/legacy-relation-inverse-migration-2.1
Dec 5, 2026
Merged

sonika-shah merged 2 commits into
2.1from
fix/legacy-relation-inverse-migration-2.1

Conversation

@sonika-shah

@sonika-shah sonika-shah commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes

Backport of #39765 to 2.1.

Fixes #39764

2.0 accepted relation types that 2.1 rejects, and the 2.1.0 data migration stored them without the checks a 2.1 write runs. A free-text inverse stopped the upgrade; other shapes got through and then left types that cannot be saved and glossary term pages that fail to load. The corrected 2.1.0 migration converts free-text inverses into relationship types. A new 2.1.2 step repairs the types and links 2.1 rejects; it runs on every upgrade, and is the only fix for clusters already on 2.1.0 or 2.1.1. Scenarios with examples: #39765 (comment)

Differences from main

  • The production code and unit tests apply unchanged.
  • 2.1 does not have the scratch-database test harness that main added in Fixes #38625: Move container tests to integration-tests and fork service unit tests #38626, which both new migration ITs use. This PR copies ScratchDatabase and ScratchDatabasePerTest from main unchanged, and narrows TestSuiteBootstrap.getDatabaseContainer() to JdbcDatabaseContainer<?>, as on main (the field already had that type).
  • The cherry-pick placed OntologyInverseRepairMigrationIT under openmetadata-service/src/test; it is moved to openmetadata-integration-tests/.../it/tests/migration/v210/, its path on main.
  • .github/java-tests/impact-map.json maps org/openmetadata/it/tests/migration/** to migrations-seed-data, as on main, so the new helper has an owner.

Decision records: ADR:2026-12-04-upgrade-turns-free-text-relation-inverses-into-relationship-types, ADR:2026-12-04-upgrade-repairs-relationship-types-2-1-rejects.

Type of change:

  • Bug fix

Tests:

UNIT_RESULTS

IT_RESULTS

E2E_RESULTS

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests around the new logic.

…#39765)

* Create a relationship type for a free-text inverse during the 2.1 upgrade

In 2.0 a glossary term relation type's inverse was free text, and a link
saved from the inverse end was stored under that text. The 2.1.0 data
migration requires every inverse to name a configured type and throws
otherwise, which halts the upgrade.

Before mapping, the migration now points each unmatched inverse at the
type it names in another case or by display name, or adds a type for it,
and renames the term links stored under the old text (dropping a row
that already exists under the new name). Links are renamed before the
settings are written, so an interrupted run repeats the repair.

* Repair relationship types the 2.1 upgrade stored without 2.1 validation

- The 2.1.0 conversion runs only when relationship_type_entity is empty
  and only inserts, so a re-run keeps what 2.1 changed since.
- A symmetric type's free-text inverse resolves to the type itself.
- A name with a space gets an encoded default predicate; a dotted name is
  stored under its quoted FQN and hash, and lookups by name quote it.
- New 2.1.2 step RelationshipTypeRepair for clusters already upgraded:
  every type can be saved again, each holds its own predicate (seed
  predicates stay free for their seeds), term links stored under no type
  point at one, and links get the type id and json 2.1 reads.

* Keep one relation type per name and quote names in type lookups

- The 2.1.0 conversion keeps one definition per name from the 2.0
  settings (the system-defined one, else the first) instead of failing
  the insert on the second copy.
- The settings synchronizer and PUT /relationshipTypes look a type up
  under its quoted FQN, so a name holding a dot updates the stored type
  instead of colliding with it.
- Decision records note the search and RDF reindex after the repair and
  the deprecated settings endpoints as a known gap.

* Match relation types by name only when resolving upgraded inverses and link texts

2.0 resolved an inverse and a stored link type by name, ignoring case, never by display
name. Matching a display name pointed a type at another type's inverse and left a one-way
pair, so links saved from the higher term id read back as the partner's inverse. Text equal
only to another type's display name now gets its own type; texts naming the same missing
type still share one.

* Pair a relationship type left without its inverse in the 2.1.2 repair

A stock 2.1.0 upgrade kept the last definition of a name 2.0 defined twice, so a type can
have no inverse while its partner names it, and a link authored from the higher term reads
as the partner's inverse on both terms. The repair now gives such a type the one live type
naming it, unless a link stored under it was authored on 2.1 from the higher term: a pair
would read that link the other way round, so the type is left and logged.

* Revert "Pair a relationship type left without its inverse in the 2.1.2 repair"

This reverts commit 6874b99. From the stored types alone, a type a duplicate name left
without its inverse looks the same as a 2.0 type that never had one, and pairing the latter
reverses links 2.0 stored from the higher term. The cosmetic gap it closed is recorded in the
decision record instead.

(cherry picked from commit 80ea0f2)
@sonika-shah
sonika-shah requested a review from a team as a code owner December 5, 2026 05:41
@sonika-shah
sonika-shah requested review from a team and pmbrull and a balanced review from Copilot and removed request for a team December 5, 2026 05:41
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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 skip-pr-checks label.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

The 2.1.0/2.1.2 migrations rewrite relationship-type definitions and glossary-term links, so incorrect repairs could misrepresent or disrupt stored relationships.

Backport to 2.1 that converts free-text relationship inverses into relationship types during the 2.1.0 migration and adds a 2.1.2 step to repair relationship types already stored by 2.1.0 on upgraded clusters. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonika-shah
sonika-shah merged commit 5a832cd into 2.1 Dec 5, 2026
48 of 51 checks passed
@sonika-shah
sonika-shah deleted the fix/legacy-relation-inverse-migration-2.1 branch December 5, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants