Skip to content

Fixes #26153: prevent Superset dashboard/chart FQN collision - #32172

Closed
akashverma0786 wants to merge 6 commits into
mainfrom
fix-26153
Closed

akashverma0786 wants to merge 6 commits into
mainfrom
fix-26153

Conversation

@akashverma0786

@akashverma0786 akashverma0786 commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes:

Fixes #26153

Superset gives dashboards and charts independent auto-increment id sequences, so a Dashboard and a Chart can end up sharing the same numeric id (e.g. dashboard id 1 and chart id 1). OpenMetadata named both entity types after that raw numeric id, so they'd collide on the exact same fullyQualifiedName (superset.1). This breaks the Lineage tab: the FQN-based lookup used to resolve the "Base" node has no way to tell the two entities apart, so it can resolve the wrong one (or fail to resolve at all).

I made Chart entities name themselves chart_{id} instead of the bare numeric id, in both the API-based and DB-based Superset connector paths. A chart can now never again collide with a same-numbered dashboard. Dashboard naming is left untouched — prefixing either side alone is enough to break the collision, and dashboards have far more external references (bookmarks, deep links) than charts, so leaving them as-is minimizes blast radius. DashboardDataModel needed no change — it already builds its FQN with an inserted .model segment, so it was never at risk of this specific collision.

Since this only changes future ingestion runs, I added a one-time v2.1.0 data migration that repairs charts already affected by this collision on existing installs — renaming them in place (same entity id, tags/owners/lineage preserved) and refreshing their search index, so no re-ingestion is required.

Type of change:

  • Bug fix

High-level design:

  • Connector (ingestion/src/metadata/ingestion/source/dashboard/superset/{api_source,db_source}.py): one-line change each — CreateChartRequest.name is now EntityName(f"chart_{chart_json.id}") instead of EntityName(str(chart_json.id)). sourceUrl is untouched in both files — it's built from Superset's own returned URL field / the raw numeric id directly, never from the new prefixed name, so links back to Superset stay exactly as reachable as before.
  • Migration (openmetadata-service/.../migration/{mysql,postgres}/v210/Migration.java + .../migration/utils/v210/SupersetChartFqnCollisionFix.java): on upgrade, finds all Superset dashboard services, walks their Chart children via the CONTAINS relationship, and renames any chart whose name is still purely numeric to chart_<id> (idempotent — re-running is a safe no-op). Refreshes the entity's search-index document afterward so stale names don't linger in Elasticsearch/OpenSearch. Split into per-database-engine wrapper classes because that's the structure every other migration in this codebase already uses; the actual fix logic lives in one shared file.
  • Considered also renaming Dashboards, or fixing the FQN-lookup itself (a separate, already-diagnosed defect where the lineage FQN search silently ignores the type query param) — both are out of scope for this PR. The connector rename is the minimal fix that closes the reported bug; the lineage-lookup defect is a systemic issue independent of Superset (Redash has the same at-risk naming pattern) and is better scoped as its own follow-up.

Tests:

Use cases covered

  • A dashboard and a chart sharing the same numeric Superset id no longer produce colliding fullyQualifiedNames.
  • The Lineage tab's root-entity lookup for the dashboard now resolves the dashboard, not the chart.
  • A chart's sourceUrl stays byte-for-byte identical to before the fix (still built from the raw, unprefixed Superset slice id).
  • An install that already ingested Superset before this fix gets its existing colliding chart entities repaired automatically on upgrade, without re-ingestion.

Unit tests

  • I added unit tests for the new/changed logic.
  • Added: openmetadata-service/src/test/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFixTest.java — 3 cases: rename + search-reindex happy path, already-renamed chart is a no-op, service with zero charts is a no-op. Tests run: 3, Failures: 0, Errors: 0.
  • Also manually verified the migration against a real MySQL database (not mocked): recreated a genuine collision on an already-ingested chart via the production update path, ran the real migration against that live database, confirmed the fix via both direct DB query and the OpenMetadata REST API. (Verification-only harness, not committed.)

Backend integration tests

  • Not applicable — this is a pure data-repair migration with no new/changed REST endpoints.

Ingestion integration tests

  • I added/updated ingestion integration tests for connector changes.
  • Updated: ingestion/tests/integration/superset/test_superset.py — extended the existing test_fetch_chart_db with assertions that yield_dashboard_chart's output has name == "chart_1" and sourceUrl still points at the real, unprefixed Superset slice id. Ran the full file against real Postgres/Superset testcontainers: 24 passed (was 23 passed before this addition), 0 failures.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Ran a real metadata ingest against a live Superset instance whose sample dataset has a dashboard and a chart sharing numeric id 1 (and, in fact, ids 1-10 collide across the board in Superset's own sample data).
  2. Before the fix: confirmed via the OpenMetadata API that both entities landed at the identical FQN, and that the Lineage tab's actual API call (GET /lineage/getLineage?fqn=...&type=dashboard) returned the chart instead of the dashboard, 10/10 dashboards affected.
  3. After the fix: re-ingested from a clean service, confirmed the dashboard and chart now have distinct FQNs (service.1 vs service.chart_1), and the same lineage API call now correctly resolves the dashboard, 0/10 broken, stable across repeated calls.
  4. Deleted a chart directly in Superset, re-ran ingestion, confirmed mark_charts_as_deleted correctly soft-deletes it in OpenMetadata (unrelated pre-existing feature, verified as a side effect of this investigation, not modified here).
  5. Simulated an upgrade scenario: manually reverted an already-fixed chart back to its old colliding name via the real production DB-update code path, ran the real migration against the live database, and confirmed via both direct SQL and the REST API that it was correctly repaired back to chart_<id> with the same entity id (no duplicate created).

UI screen recording / screenshots:

Not applicable — no UI changes.

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. (No JSON Schema changes in this PR.)
  • For UI changes: I attached a screen recording and/or screenshots above. (N/A — no UI changes.)
  • 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.

Greptile Summary

The PR prevents new Superset chart/dashboard FQN collisions by prefixing chart names and adds a v2.1.0 repair for existing numeric chart names.

  • Applies chart_<id> naming in both Superset API and database connector paths.
  • Renames existing numeric Superset charts while preserving entity IDs.
  • Refreshes chart and parent-dashboard search projections after migration.
  • Adds connector and migration-focused tests.

Confidence Score: 4/5

The PR is not yet safe to merge because a database or per-chart repair failure can still be recorded as a successful migration while legacy FQN collisions remain.

The migration wrappers and utility-level catches continue to suppress failures, so the migration workflow can persist v2.1.0 completion without repairing all affected charts and will not automatically rerun the skipped work.

Files Needing Attention: openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java, openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java, openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFix.java

Important Files Changed

Filename Overview
ingestion/src/metadata/ingestion/source/dashboard/superset/api_source.py Prefixes API-ingested chart names while leaving source URLs unchanged.
ingestion/src/metadata/ingestion/source/dashboard/superset/db_source.py Applies the same collision-resistant naming to database-ingested charts.
openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFix.java Repairs legacy numeric chart names and refreshes search projections, but suppressed repair failures can leave installations only partially migrated.
openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java Invokes the repair during MySQL migration but still converts repair failures into successful migration completion.
openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java Invokes the repair during PostgreSQL migration but still converts repair failures into successful migration completion.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  S[Superset chart with numeric ID] --> C[Connector emits chart_ID]
  C --> O[OpenMetadata chart with distinct FQN]
  L[Legacy numeric chart] --> M[v2.1.0 migration]
  M --> D[(Rename in metadata database)]
  D --> I[Refresh chart index]
  D --> P[Refresh parent dashboard indexes]
Loading

Reviews (5): Last reviewed commit: "Align with latest migration conventions ..." | Re-trigger Greptile

Context used (3)

Superset dashboards and charts use independent auto-increment id
sequences, so a Dashboard and a Chart can end up with the same numeric
id and therefore the same fullyQualifiedName (e.g. "superset.1"). This
causes the Lineage tab's FQN-based lookup to resolve the wrong entity
as the "Base" node.

Chart entities are now named `chart_{id}` instead of the bare numeric
id in both the API-based and DB-based Superset connector paths, so a
chart can never again collide with a same-numbered dashboard. Dashboard
naming is left untouched (prefixing either side alone is sufficient to
break the collision, and dashboards have far more external references).

Adds a v210 data migration that repairs already-collided chart entities
on existing installs (renamed in place, same entity id, search index
refreshed), plus a unit test for it. Adds a regression test asserting
the chart's name is correctly prefixed while its sourceUrl stays
untouched -- still built from the real, unprefixed Superset slice id,
so the link back to Superset remains exactly as reachable as before.
@akashverma0786
akashverma0786 requested review from a team as code owners August 27, 2026 10:44
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

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

@akashverma0786 akashverma0786 added the safe to test Add this label to run secure Github workflows on PRs label Aug 27, 2026
Comment on lines +20 to +23
SupersetChartFqnCollisionFix.fixSupersetChartFqnCollision(handle, collectionDAO);
} catch (Exception e) {
LOG.error("Failed to fix Superset chart/dashboard FQN collisions in v210 migration.", e);
}

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.

P1 Migration failures are suppressed

When the Superset service query or a chart update fails, these catch blocks prevent the exception from reaching the migration runner, so the v2.1.0 migration is recorded as successful while legacy FQN collisions remain and lineage lookup can continue resolving the wrong entity. Core repair failures should propagate so the upgrade fails and can be retried; the PostgreSQL wrapper and the utility's query and per-chart catches have the same issue.

Knowledge Base Used: Metadata platform service

Comment on lines +29 to +72
"SELECT id FROM dashboard_service_entity WHERE serviceType = 'Superset'";

@Test
void fixSupersetChartFqnCollisionRenamesNumericChartAndReindexes() {
Handle handle = mock(Handle.class, RETURNS_DEEP_STUBS);
CollectionDAO collectionDAO = mock(CollectionDAO.class);
CollectionDAO.EntityRelationshipDAO relationshipDAO =
mock(CollectionDAO.EntityRelationshipDAO.class);
CollectionDAO.DashboardServiceDAO dashboardServiceDAO =
mock(CollectionDAO.DashboardServiceDAO.class);
CollectionDAO.ChartDAO chartDAO = mock(CollectionDAO.ChartDAO.class);
SearchRepository searchRepository = mock(SearchRepository.class);
Entity.setSearchRepository(searchRepository);

when(collectionDAO.relationshipDAO()).thenReturn(relationshipDAO);
when(collectionDAO.dashboardServiceDAO()).thenReturn(dashboardServiceDAO);
when(collectionDAO.chartDAO()).thenReturn(chartDAO);

UUID serviceId = UUID.randomUUID();
UUID chartId = UUID.randomUUID();

stubSupersetServiceRows(handle, serviceId);
when(relationshipDAO.findTo(
serviceId, Entity.DASHBOARD_SERVICE, Relationship.CONTAINS.ordinal(), Entity.CHART))
.thenReturn(List.of(relationship(chartId)));

String serviceFqn = "superset";
DashboardService service =
new DashboardService()
.withId(serviceId)
.withName("superset")
.withFullyQualifiedName(serviceFqn);
Chart chart =
new Chart().withId(chartId).withName("1").withFullyQualifiedName(serviceFqn + ".1");

when(dashboardServiceDAO.findEntityById(serviceId)).thenReturn(service);
when(chartDAO.findEntityById(chartId)).thenReturn(chart);

SupersetChartFqnCollisionFix.fixSupersetChartFqnCollision(handle, collectionDAO);

String expectedFqn = FullyQualifiedName.add(serviceFqn, "chart_1");
assertEquals("chart_1", chart.getName());
assertEquals(expectedFqn, chart.getFullyQualifiedName());
verify(chartDAO).update(chart);

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 Mocks hide migration behavior

These tests replace the database handle, project DAOs, and search repository with mocks and primarily verify method calls, so they remain green when the migration cannot persist the renamed FQN, violates a real database constraint, or leaves the actual search document stale. Exercise the repair against observable database and search state instead.

Context Used: CLAUDE.md (source)

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java
#	openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java
Dashboard's own search-index document embeds a denormalized copy of its
charts' id/name (DashboardIndex's "charts" field), which the migration's
raw DB update bypasses -- so a renamed chart's parent Dashboard(s) kept
showing the stale pre-fix name in search. Now reindexes each parent
Dashboard too, non-fatal per-dashboard, matching the same pattern already
used for the chart's own reindex.

Also fixed two catch blocks that logged e.getMessage() instead of the
exception itself, silently dropping the stack trace (inconsistent with
this file's own reindexChart catch, which already did it correctly).
@github-actions

Copy link
Copy Markdown
Contributor

The Java checkstyle failed.

Please run mvn spotless:apply in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Java code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

Both reindexChart and reindexParentDashboards were fetching entities
via the raw DAO (findEntityById), which returns only the entity's own
stored JSON -- relationship fields like Chart's "dashboards" and
Dashboard's "charts" are populated separately by the repository's
setFields() only when explicitly requested via Fields. Reindexing a
raw-DAO-fetched entity re-serializes those fields as null, blanking
them out in the existing search document instead of merely leaving
them stale -- a real regression, caught in review.

Both reindex paths now re-fetch through Entity.getEntityRepository(...)
with the relevant relationship field requested, matching this
codebase's established pattern (used across many other migrations)
instead of the raw DAO. Test updated to register mock repositories via
the same Entity.registerEntity(...) used elsewhere, with an @AfterEach
Entity.cleanup() so the mocks can't leak into unrelated tests running
later in the same JVM -- also closing a latent gap in the existing
Entity.setSearchRepository(...) call, which had no teardown either.
Compared against ConversationMigration/ConversationReferenceMigration
(merged into main just before this PR, the newest migration code in
this same v210 folder) rather than the older migration files this PR
originally modeled its style on:

- catch (RuntimeException e) instead of the broader catch (Exception e)
  -- matches the newer sibling files exactly, and is closer to this
  repo's own documented rule against catching generic Exception.
  Verified safe by compiling clean: a checked exception escaping any
  of these try blocks would be a hard compile error, not caught silently.
- Utility class marked final, per this repo's documented rule for
  private-constructor static utility classes.
@github-actions

github-actions Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ Playwright Results — workflow succeeded

Validated commit 8fd24c65b139990d2d2dc922570de8597f7722ea in Playwright run 34040296391, attempt 1.

✅ 619 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) 46m 50s

⏱️ Max setup 4m 31s · max shard execution 18m 35s · max shard-job elapsed before upload 21m 27s · reporting 6s

🌐 241.46 requests/attempt · 2.74 app boots/UI scenario · 8.88% common-shard skew

Optimization targets still in progress:

  • Browser traffic was 241.46 requests per attempt (convergence target: fewer than 200).
  • Application boot ratio was 2.74 per UI scenario (1780 boots / 649 scenarios; convergence target: at most 1).
Shard Passed Failed Flaky Skipped Lifecycle failed Lifecycle flaky
✅ Shard chromium-01 142 0 0 0 0 0
✅ Shard chromium-02 133 0 0 0 0 0
✅ Shard chromium-03 124 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 30 0 0 0 0 0
✅ Shard ingestion-02 33 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

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/migration/mysql/v210/Migration.java
#	openmetadata-service/src/main/java/org/openmetadata/service/migration/postgres/v210/Migration.java
@gitar-bot

gitar-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 3 resolved / 3 findings

Prevents Superset dashboard/chart FQN collisions by prefixing chart names with chart_ in both API and database connectors, and adds a v2.1.0 migration to repair existing numeric chart names while preserving entity IDs and refreshing search indexes for both charts and parent dashboards. Exception logging, parent dashboard reindexing, and search document integrity issues addressed.

✅ 3 resolved
✅ Quality: Exception logging drops stack traces in migration fix

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFix.java:62-64 📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFix.java:102-104
In SupersetChartFqnCollisionFix.findSupersetServiceIds (lines 62-64) and fixChart (lines 102-104), exceptions are caught broadly and logged with only e.getMessage(), discarding the stack trace. This violates the project's Java exception-handling rule (pass the exception as the last logger argument) and makes real migration failures hard to diagnose since they are only surfaced at WARN with no trace. Change to LOG.warn("Error ...: {}", chartId, e) / LOG.warn("Error finding Superset services", e) so the stack trace is preserved.

✅ Edge Case: Parent Dashboard search index not refreshed after chart rename

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFix.java:88-102
The migration reindexes the renamed chart (reindexChart) but not the parent Dashboard, whose search-index document embeds chart EntityReferences (name/fullyQualifiedName). After the rename these embedded values may remain stale in Elasticsearch/OpenSearch until the next full reindex, so dashboard search results could still show the old bare-numeric chart name/FQN. Consider also refreshing the owning Dashboard's index (or documenting that a 'Recreate Search Indexes' run may be needed) for consistency.

✅ Bug: Parent dashboard reindexed with null charts blanks search doc

📄 openmetadata-service/src/main/java/org/openmetadata/service/migration/utils/v210/SupersetChartFqnCollisionFix.java:129-143
reindexParentDashboards fetches the dashboard with dashboardDAO().findEntityById(record.getId()), which returns the bare stored JSON. The charts relationship field is only populated by DashboardRepository.setFields when the requested fields contain "charts" (DashboardRepository.java:81-84), so here dashboard.getCharts() is null. Passing that entity to updateEntityIndex re-serializes the dashboard with an empty/null charts field, overwriting the dashboard's existing search document and removing all charts.name/charts.description data — the opposite of the intended refresh, and a regression versus leaving the stale name. Fetch the dashboard through the repository with the "charts" field (and any other required reindex fields) before reindexing.

Options

Display: compact → Showing less information.

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

@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

@harshach

Copy link
Copy Markdown
Collaborator

@akashverma0786 are you still working on this? if its not, lets close the PR

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.

Superset: Dashboard and Chart FQN collision when they share the same numeric ID causes incorrect lineage rendering

2 participants