Skip to content

[2.0] fix(glossary): include cardinality on default term relation types - #33554

Open
gh-bot-collate[bot] wants to merge 1 commit into
2.0from
backport/2.0/pr-28376
Open

gh-bot-collate[bot] wants to merge 1 commit into
2.0from
backport/2.0/pr-28376

Conversation

@gh-bot-collate

@gh-bot-collate gh-bot-collate Bot commented Sep 18, 2026

Copy link
Copy Markdown

Automated backport of #28376 to 2.0.

Source PR #28376
Author @sonika-shah
Merge commit 4c33d0a228011ac34c5f07f901cace05a333cb89
Method Clean cherry-pick — identical to the commit on main.

Opened from openmetadata-collate, which holds the credentials needed to open a PR here. It merges itself once every check passes — no review needed. If a check fails it stays open and the author of #28376 is asked to look.

resolver run

RetriggerConfidence Score: 4/5

The backfill appears behaviorally safe, but the explicit Java method-structure requirement should be satisfied before merging.

Findings

  1. P2 Oversized migration methods
Summary

This backport makes the ten built-in glossary relation types explicitly unbounded MANY_TO_MANY relations on fresh installations and upgrades existing settings whose system-defined relations still have null cardinality.

  • Adds MySQL and PostgreSQL 2.0.3 migration entry points that backfill legacy settings.
  • Normalizes migrated relations so no source or target maximum is enforced.
  • Updates default settings and integration assertions to expose explicit cardinality.
  • Adds placeholder native SQL migration files because the backfill runs in Java.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[2.0.3 migration runner] --> B[Load glossary relation settings]
  B --> C{System-defined and cardinality null?}
  C -->|No| D[Leave relation unchanged]
  C -->|Yes| E[Set MANY_TO_MANY]
  E --> F[Normalize sourceMax and targetMax to null]
  D --> G{Any relation changed?}
  F --> G
  G -->|Yes| H[Persist settings JSON]
  G -->|No| I[Skip update]
  H --> J[Server initializes SettingsCache]
  I --> J
Loading

Reviews (1) · Last reviewed commit: "fix(glossary): include cardinality on de..."

…8376)

* fix(glossary): include cardinality on default term relation types

The system-seeded glossary term relation types (relatedTo, synonym, broader,
narrower, partOf, hasPart, etc.) were created without a cardinality value, so
the GET /v1/system/settings/glossaryTermRelationSettings response omitted the
field for defaults while returning it for custom relations.

The UI fell back to MANY_TO_MANY for every default and, on the next PUT, wrote
that fallback back into the system relations - overriding any intended value.

Set the expected cardinality on each default in SettingsCache and add a 2.0.2
data migration that backfills the field for installs that were already seeded
without it. broader/narrower follow strict SKOS semantics (ONE_TO_MANY /
MANY_TO_ONE - a term has at most one broader parent); all other system
relations stay MANY_TO_MANY.

* chore(migration): move glossary cardinality backfill to 2.0.3

The 2.0.2 / v202 migration slot was taken by search-settings repairs on
main. Relocate the glossary term relation cardinality backfill to the
next free version (2.0.3 / v203) so it runs after the existing 2.0.2
migrations without colliding with them.

* fix(migration): cast settings json to jsonb on postgres in v203 backfill

The glossary cardinality backfill bound the settings payload as a string
into openmetadata_settings.json, which is jsonb on Postgres - Postgres
refuses the implicit varchar->jsonb cast and the whole migration (and
therefore TestSuiteBootstrap / every IT in the lane) aborted. Select the
DB-specific UPDATE the way PiiRecognizerMigrationUtil / v1126 do: plain
:json for MySQL, :json::jsonb for Postgres.

* fix(glossary): seed system relation cardinality as unbounded MANY_TO_MANY

Resolves the enum/bounds inversion flagged in review by not imposing any
per-relation cardinality on the system defaults - the original bug was only
that GET returned a null cardinality, not that hierarchy needed enforcing.

- SettingsCache: broader/narrower now MANY_TO_MANY with null bounds, matching
  every other system default. GET returns a non-null cardinality and the UI no
  longer falls back to (and persists) a guessed value - with zero new
  enforcement, so existing terms with multiple broader parents keep working.
- v203 migration: backfill null cardinality on system-defined relations to
  MANY_TO_MANY and derive bounds via the canonical normalize(), deleting the
  hand-written (inverted) bounds switch and per-relation map.
- IT: assert exact cardinality (MANY_TO_MANY) and null sourceMax/targetMax for
  all 10 system relations, so an inverted or bounded value fails the test.

(cherry picked from commit 4c33d0a)
@github-actions

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 Sep 18, 2026

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit d44465f44d246aac12a9da2068a18d7b39c27a1e in Playwright run 35330245304, attempt 1.

✅ 766 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 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) 57m 51s

⏱️ Max setup 3m 3s · max shard execution 17m 12s · max shard-job elapsed before upload 20m 41s · reporting 5s

🌐 201.40 requests/attempt · 2.51 app boots/UI scenario · 24.42% common-shard skew

Optimization targets still in progress:

  • Common shard skew was 24.42% (convergence target: at most 15%).
  • Browser traffic was 201.4 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.51 per UI scenario (1975 boots / 788 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 133 0 0 0 0 0
✅ Shard chromium-02 148 0 0 0 0 0
✅ Shard chromium-03 173 0 0 0 0 0
✅ Shard chromium-04 154 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 ingestion-01 1 0 0 0 0 0
✅ Shard reindex-01 2 0 0 0 0 0
✅ Shard search-01 11 0 0 0 0 0
✅ Shard search-rbac-01 29 0 0 0 0 0

📦 Download artifacts

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

Comment on lines +37 to +41
public void backfillGlossaryTermRelationCardinality() {
GlossaryTermRelationSettings settings = loadSettings();
if (settings == null || settings.getRelationTypes() == null) {
return;
}

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.

P2 Oversized migration methods

The new backfill method combines loading, filtering, mutation, normalization, logging, and persistence in roughly 25 lines, and it exits through an early guard. The repository’s Java guide requires focused methods of about 15 lines or fewer and one trailing return per method. loadSettings also introduces an early return, and the new integration-test method exceeds the method-size guideline. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants