Skip to content

fix(dataProducts): key ODPS import identity on productID, not display name - #33993

Merged
sonika-shah merged 17 commits into
mainfrom
fix/odps-import-productid-identity
Nov 4, 2026
Merged

sonika-shah merged 17 commits into
mainfrom
fix/odps-import-productid-identity

Conversation

@sonika-shah

@sonika-shah sonika-shah commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #33995

Problem

ODPS import derived a data product's entity name from the ODPS name (the editable display label), sanitized into a slug — e.g. "[DEV] Alarms Info" → "DEV_Alarms_Info". The ODPS productID (the stable identifier) was validated as required but never used.

Because the merge/update path matches an existing product by its entity name, this caused:

  1. Re-import creates a second product instead of updating. When the display name changes between imports (or when re-importing an exported doc), the derived name differs, so no existing product is matched → a new, separate product is created for the same source product, leaving the original untouched. (OpenMetadata still blocks two products with the same name — these are distinct names for one logical product.)
  2. Export/import are asymmetric. toODPS writes productID from the entity identifier and name from displayName, so an exported document couldn't be re-imported onto itself.

Fix

Map the ODPS fields onto OpenMetadata's identity/display split, mirroring the exporter:

  • ODPS productID → entity name (sanitized to an FQN-safe slug) — the identifier and update key
  • ODPS name → displayName

Matching keys on productID, so a re-import updates the same product. Additional robustness:

  • Match by the raw productID first (the exact FQN export writes), then the sanitized name — so a product whose name isn't a slug (e.g. Customer 360) still matches instead of forking.
  • Quote the lookup FQN so dotted productIDs (com.acme.orders) match.
  • Fall back to the name when a productID has no characters valid for an entity name (e.g. all non-ASCII), so such a document still imports as it did before.

Behavior note: identity moves from the display-name slug to the productID slug. Products imported before this change are keyed on the old display-name slug and have no stored productID, so they can't be migrated; their next re-import matches on productID going forward.

Tests

  • ODPSConverterTest updated to the new mapping + a productID-not-sanitizable fallback case (36/36 green).
  • DataProductResourceIT: importFromODPS_matchesExistingProductByProductId (dotted productID re-import updates the same product) and importFromODPS_matchesExistingNonSlugProductByProductId (Customer 360 re-import updates, not forks). Verified RED→GREEN on a real MySQL + ES stack.

Summary by Gitar

  • UI changes:
    • ODPSImportModal guard now validates the YAML productID against the current product's FQN or name, not the ODPS name
    • Import mismatch and missing-value messages across locale files now refer to productID

This will update automatically on new commits.

… name

ODPS import derived the entity name from the ODPS `name` (display label),
sanitized: "[DEV] Alarms Info" became "DEV_Alarms_Info". `productID` (the
stable ODPS identifier) was validated but never used. Since the merge path
matches an existing product by entity name, re-importing a product whose
display name differs from its slug never matched the existing one — it
created a duplicate and left the original untouched.

This also disagreed with our own exporter: toODPS writes productID from the
entity identifier and name from displayName, so an exported document could
not be re-imported onto itself.

Map ODPS productID -> entity name (sanitized to an FQN-safe slug) and ODPS
name -> displayName. Matching then keys on productID, so re-imports update
the same product. Import and export are now symmetric.

Updates ODPSConverterTest assertions to the new mapping and adds
DataProductResourceIT#importFromODPS_matchesExistingProductByProductId,
which fails without the fix (re-import creates a duplicate).
Copilot AI lite review requested due to automatic review settings September 25, 2026 04:09
@sonika-shah
sonika-shah requested a review from a team as a code owner September 25, 2026 04:09

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 reached their quota limit.

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Sep 25, 2026

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 reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — manual (2026-09-29T05:14:55Z)

The entry left the queue before it was built, so no checks ran against it.

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 reached their quota limit.

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 reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

🚦 Removed from the merge queue — failed_checks (2026-09-29T14:18:41Z)

Blocked the queue: integration-tests-postgres-opensearch

sonika-shah and others added 2 commits October 6, 2026 10:46
…ctid-identity

# Conflicts:
#	openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 836 → 836
- 0 added, 0 removed, 8 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/e2e/fixtures/pages.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/ContextCenterUtil.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/entity.ts
  openmetadata-ui/src/main/resources/ui/src/components/ContextCenter/CreateMemoryModal/CreateMemoryModal.component.tsx
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/table.ts
  openmetadata-ui/src/main/resources/ui/src/generated/entity/data/topic.ts
  openmetadata-ui/src/main/resources/ui/src/pages/ContextCenterPage/ContextCenterMemoriesPage/ContextCenterMemoriesPage.tsx

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

…ctid-identity

# Conflicts:
#	.github/playwright/impact-map.generated.json
The import resolves the target product by productID, but the modal guard
still compared the ODPS display name, so a YAML whose name matched the
current product could update (or create) a different one, and a re-import
with an edited display name was blocked. Compare productID against the
product FQN/name (or its sanitized slug, the backend fallback) instead.

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.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 81%
81.32% (138057/169765) 68.33% (49767/72824) 71.37% (27959/39171)

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.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🔄 Playwright impact map auto-refreshed

This PR touched specs or UI source that changed the source→spec routing map. I regenerated .github/playwright/impact-map.generated.json and pushed the diff to this branch.

- source entries: 1029 → 1029
- 0 added, 0 removed, 12 changed spec-list

Entries whose spec list changed:
  openmetadata-ui/src/main/resources/ui/playwright/constant/config.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/domain/DataProduct.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/domain/Domain.ts
  openmetadata-ui/src/main/resources/ui/playwright/support/fixtures/userPages.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/admin.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/common.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/entity.ts
  openmetadata-ui/src/main/resources/ui/playwright/utils/polling.ts
  openmetadata-ui/src/main/resources/ui/src/components/common/NextPrevious/NextPrevious.tsx
  openmetadata-ui/src/main/resources/ui/src/components/common/NextPreviousWithOffset/NextPreviousWithOffset.tsx
  … and 2 more

What is this file? It is the auto-generated half of Playwright's PR planner. It routes "if source X changes, run specs Y" by walking spec imports and cross-referencing getByTestId strings. Hand-authored routing in impact-map.json always wins on conflict.

What if I want to regenerate locally instead? Run this before pushing your next change to skip the bot commit:

python3 .github/scripts/generate_playwright_impact_map.py
git add .github/playwright/impact-map.generated.json
git commit --amend --no-edit  # or a separate commit

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.

@gitar-bot

gitar-bot Bot commented Nov 4, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 4 closed / 4 findings

🔴 High risk · The new productID-based import matching could update an unintended data product or create duplicates, disrupting stored metadata integrity.

Switches ODPS import identity from the display-name slug to the productID, so re-imports update the same data product instead of creating a duplicate. Matching tries the raw productID first, then the sanitized name, and the lookup FQN is quoted so dotted IDs like com.acme.orders resolve. The ODPSImportModal guard and locale messages now validate against productID.

All four issues raised this session were resolved: dotted-ID re-imports, export→re-import for non-slug names like Customer 360, the UI guard checking the wrong field, and the sanitized fallback letting the guard pass on a sibling match. No issues found.

✅ 4 closed
✅ Bug: Re-import still fails for productIDs containing '.'

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ODPSConverter.java:163 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ODPSConverter.java:82-85
The entity name now comes from sanitizeEntityName(productID), and that sanitizer keeps .. productIDs with dots are common: reverse-domain IDs like com.acme.orders, the marketing.sales-analytics fixture in ODPSConverterTest, and FQN-style IDs from our own toODPS, which puts the FQN in productID. When a data product is stored, its FQN is quoteName(name), so a dotted name is saved as "a.b". But findExistingByName calls repository.getByName(null, name, ...) with the raw unquoted name, and DataProductRepository leaves quoteFqn false, so that lookup never matches. The PUT import then goes down the create path with a name that already exists and fails with a conflict. So for dotted productIDs, re-import (and export→re-import) still breaks, which is the bug this PR is meant to fix. The fix is to look up with FullyQualifiedName.quoteName(name), the same way DataProductRepository line 1169 does, or to replace . during sanitization. Adding a test that uses a dotted productID would cover this.

✅ Bug: productID slugging breaks export→re-import for non-slug entity names

📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ODPSConverter.java:163 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DataProductResource.java:1878-1879
The PR says export and import are now symmetric, but that only holds when the entity name is already a slug of 64 characters or fewer. toODPS writes the raw FQN into productID. On import, sanitizeEntityName turns every character outside [a-zA-Z0-9_.-] into _ and cuts the result at 64 characters. OpenMetadata's entityName is much looser: it allows spaces, brackets, colons and other punctuation, up to 256 characters. So a product created in the UI or through the API as Customer 360 or [DEV] Alarms Info exports productID: Customer 360. Re-importing that document gives the name Customer_360. findExistingByName then finds no match, and a duplicate product is created, which is the bug this PR set out to fix.

The 64-character cut also makes the productID key lossy. Two distinct productIDs that share their first 64 sanitized characters, such as long URN-style IDs, or two that differ only in punctuation (urn:acme:orders vs urn/acme/orders), resolve to the same entity name. The second import then silently smart-merges into, or with replace overwrites, an unrelated product.

Fix: before sanitizing, look up the existing product by the raw productID taken as an FQN, and only fall back to the slug when that lookup finds nothing. Also limit sanitization to what entityName actually forbids (", ::, >, control characters, max 256) so that IDs don't collide.

✅ Bug: UI overwrite guard still checks ODPS name, backend now targets productID

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DataProductResource.java:1856-1863 📄 openmetadata-service/src/main/java/org/openmetadata/service/util/ODPSConverter.java:166-168
ODPSImportModal.handleImport (ODPSImportModal.component.tsx:143-176) stops an import from a data product page from overwriting a different product. It does this by checking that product.details.<lang>.name equals the current product's displayName or name. After this PR, mergeOrCreateDataProductFromODPS picks the target product by productID (first the raw value, then the sanitized slug). name only becomes the displayName. That leaves the guard checking a field the backend no longer uses to pick the target, and it fails in two ways:

  1. Wrong product overwritten. Say a YAML has name equal to the current product's displayName but a productID that belongs to a different product. The guard lets it through, and the PUT smart-merges or replaces that other product. Preventing this is the guard's whole purpose.
  2. Valid re-import blocked. Say the user changes the display label in the YAML, the exact case this PR is meant to support. The guard rejects the YAML even though its productID matches the current product.

The Playwright guard tests still set name and productID to the same value, so neither case is covered.

Fix: have the guard read productID, the same way ODPSConverter.selectProductId does: use the en entry, falling back to the first language. Accept it when it equals the product's fullyQualifiedName or name, or when it sanitizes to the product's name. Update the comment and the odps-yaml-name-* messages to match.

✅ Edge Case: Sanitized-match fallback lets guard pass when raw productID hits sibling

📄 openmetadata-ui/src/main/resources/ui/src/components/DataProducts/ODPSImportModal/ODPSImportModal.component.tsx:173-177 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DataProductResource.java:1860-1863
The backend checks the raw productID first and only falls back to the sanitized slug when nothing matches (DataProductResource.mergeOrCreateDataProductFromODPS, L1860-1863). The UI guard accepts the YAML whenever sanitizeProductId(yamlProductId) === existingDataProduct.name and never checks whether the raw productID names a different product. Example: two products, Customer 360 and Customer_360, both exist (both are valid entity names). On the Customer_360 page, a YAML with productID Customer 360 gets past the guard because it sanitizes to Customer_360. The backend then finds Customer 360 by raw name and overwrites that sibling, which is the case this guard is meant to block. Fix: only accept the sanitized match when the raw productID doesn't already belong to another product. Either look up the raw productID first (e.g. getDataProductByName) and block if it returns a different id, or drop the sanitized fallback whenever the raw productID differs from the sanitized one and the raw lookup succeeds.

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

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

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

Labels

backend 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.

ODPS import: identity keyed on display name instead of productID (duplicates on re-import)

6 participants