Repository navigation
Fixes #26153: prevent Superset dashboard/chart FQN collision - #32172
akashverma0786 wants to merge 6 commits into
Conversation
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.
❌ PR checklist incompleteThis 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 |
| SupersetChartFqnCollisionFix.fixSupersetChartFqnCollision(handle, collectionDAO); | ||
| } catch (Exception e) { | ||
| LOG.error("Failed to fix Superset chart/dashboard FQN collisions in v210 migration.", e); | ||
| } |
There was a problem hiding this comment.
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
| "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); |
There was a problem hiding this comment.
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).
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
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.
✅ Playwright Results — workflow succeededValidated commit ✅ 619 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 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) 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:
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
Code Review ✅ Approved 3 resolved / 3 findingsPrevents Superset dashboard/chart FQN collisions by prefixing chart names with ✅ 3 resolved✅ Quality: Exception logging drops stack traces in migration fix
✅ Edge Case: Parent Dashboard search index not refreshed after chart rename
✅ Bug: Parent dashboard reindexed with null charts blanks search doc
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|
@akashverma0786 are you still working on this? if its not, lets close the PR |



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
1and chart id1). OpenMetadata named both entity types after that raw numeric id, so they'd collide on the exact samefullyQualifiedName(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.DashboardDataModelneeded no change — it already builds its FQN with an inserted.modelsegment, so it was never at risk of this specific collision.Since this only changes future ingestion runs, I added a one-time
v2.1.0data 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:
High-level design:
ingestion/src/metadata/ingestion/source/dashboard/superset/{api_source,db_source}.py): one-line change each —CreateChartRequest.nameis nowEntityName(f"chart_{chart_json.id}")instead ofEntityName(str(chart_json.id)).sourceUrlis 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.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 theCONTAINSrelationship, and renames any chart whose name is still purely numeric tochart_<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.typequery 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
fullyQualifiedNames.sourceUrlstays byte-for-byte identical to before the fix (still built from the raw, unprefixed Superset slice id).Unit tests
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.Backend integration tests
Ingestion integration tests
ingestion/tests/integration/superset/test_superset.py— extended the existingtest_fetch_chart_dbwith assertions thatyield_dashboard_chart's output hasname == "chart_1"andsourceUrlstill points at the real, unprefixed Superset slice id. Ran the full file against real Postgres/Superset testcontainers:24 passed(was23 passedbefore this addition), 0 failures.Playwright (UI) tests
Manual testing performed
metadata ingestagainst a live Superset instance whose sample dataset has a dashboard and a chart sharing numeric id1(and, in fact, ids1-10collide across the board in Superset's own sample data).GET /lineage/getLineage?fqn=...&type=dashboard) returned the chart instead of the dashboard, 10/10 dashboards affected.service.1vsservice.chart_1), and the same lineage API call now correctly resolves the dashboard, 0/10 broken, stable across repeated calls.mark_charts_as_deletedcorrectly soft-deletes it in OpenMetadata (unrelated pre-existing feature, verified as a side effect of this investigation, not modified here).chart_<id>with the same entity id (no duplicate created).UI screen recording / screenshots:
Not applicable — no UI changes.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.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.
chart_<id>naming in both Superset API and database connector paths.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
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]Reviews (5): Last reviewed commit: "Align with latest migration conventions ..." | Re-trigger Greptile
Context used (3)