Skip to content

Fixes 37376: Let data products take assets from subdomains of their domain - #39252

Merged
karanh37 merged 8 commits into
mainfrom
karanh37/issue-37376
Dec 1, 2026
Merged

karanh37 merged 8 commits into
mainfrom
karanh37/issue-37376

Conversation

@karanh37

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #37376

With Data Product Domain Validation enabled, a data product only accepted assets assigned directly to its own domain. The domain's Assets tab counts its whole subtree. A data product now accepts assets from its domain and any subdomain, at any depth. The reverse still fails (a subdomain's data product can't take a parent-domain asset), and a domain whose name merely shares a prefix (Sales vs SalesOps) is not a subdomain. The rule is recorded in docs/decisions/2026-11-30-a-data-product-accepts-assets-from-its-domain-subtree.md.

Type of change:

  • Bug fix

High-level design:

One check, used by every path that applies the rule. DomainRepository.isWithinAnyDomain(domainIds, scopeDomainIds, knownFqns) is true on an exact id match. Otherwise it compares stored FQNs with FullyQualifiedName.isParent. Callers used to compare raw ids (Collections.disjoint). They are:

  • LogicOps.validateDataProductDomainMatch, the rule itself. It reuses FQNs only from server-resolved data-product domains; the asset's domain FQNs come from the request body, so they are looked up by id and never trusted.
  • DataProductRepository#conflicts, the detach mirror. It is used when a data product's domain changes, by the Domain-page asset move and its dry run, and by domain delete. reconcileConflicts resolves FQNs once per 200-asset chunk.
  • UI: the Add Assets picker (getQueryFilterToIncludeDomain) now uses term + prefix per domain, the same query shape the domain Assets tab uses. The asset page's data-product picker (fetchDataProductsElasticSearch) widens the asset's domains to their ancestors.

Paths that re-home or strip an asset's domain keep the rule true for subtree assets:

  • Data product domain move (planDomainMove):
    • An asset in an old subdomain that the new domains still cover stays where it is, whether it holds that domain directly or inherits it.
    • Every other asset leaves the old domains and each old subdomain it actually holds (with that domain's lineage), then joins the new domains. Search also drops the inherited old subdomains.
    • When there are no old subdomains, or no new domains, the move behaves as it does on main.
  • Domain hard delete: cleanup captures the domain's direct assets. When the delete lifecycle closes (after the edges are gone, in the same transaction), they and their inheriting descendants are reconciled by their effective domains: their remaining own domains, or the ones they now inherit. This runs only when the rule is on and a surviving ancestor domain holds a data product, which is the one case where a subtree asset can keep a data product past the cascade. Deleting a root domain does no extra work.

Alternatives rejected:

  • Expanding every data product's domains to its descendants: that needs a subtree query on every rule evaluation.
  • Leaving the move and delete paths unchanged: assets would end up in two domains, or uneditable.

Tests:

Use cases covered

  • An asset in Sales.Emea.Retail can join a Sales data product, through bulk Add Assets and through a PATCH on the asset. The asset stays editable.
  • A SalesOps asset is rejected by a Sales data product, including when the PATCH forges a Sales.x FQN onto the SalesOps id.
  • Moving a Sales data product to Marketing re-homes its Sales.Emea assets to [Marketing] only. An inheriting asset leaves Emea's Assets listing and joins Marketing's.
  • Widening an Emea data product to Sales keeps a held Retail asset and an inheriting Retail asset where they are.
  • Moving an asset from Retail to Emea on the Domain page keeps its Sales data product.
  • Hard-deleting Sales.Emea detaches the Sales data product from a now domainless asset and from its inheriting descendant. It keeps the data product on an asset whose schema still gives it Sales.
  • UI: the Add Assets picker queries the domain subtree, the asset-page picker offers ancestor-domain data products, and quoted FQNs containing dots are handled.

Unit tests

  • I added unit tests for the new/changed logic.
  • RuleEngineTest#assetInASubdomainOfTheDataProductDomainSatisfiesTheDomainRule covers a grandchild domain (accepted), a prefix sibling (rejected), the parent→subdomain direction (rejected) and a forged request FQN (rejected).
  • Jest: DomainFilterUtils.test.ts (subtree clauses, getDomainFqnsWithAncestors), DomainUtils.test.tsx, dataProductAPI.test.ts.
  • Ran on the final code: RuleEngineTest 17/17, EntityCsvTest 72/72, DomainRepositoryListingTest 7/7, DataProductDomainContainmentRepairTest 6/6 and DataProductIndexMappingTest 2/2 all pass. Jest: DomainFilterUtils.test.ts, DomainUtils.test.tsx, dataProductAPI.test.ts, DataProductsContainer, DataProductsSection and DomainTreeView.integration all pass.
  • LogicOps.java has no unit test that references it by name. RuleEngineTest exercises it through RuleEngine.apply.
  • Not run: the DataProductsDetailsPage Jest suite (which fails to load because of the marked dependency) and two other suites (which can't resolve emojibase-data). Both are local dependency problems in the shared node_modules.

Backend integration tests

  • I added integration tests in openmetadata-integration-tests/ for the changed write paths.
  • DataProductResourceIT:
    • test_subdomainAssetJoinsParentDomainDataProduct
    • test_domainChangeRehomesSubdomainAssets
    • test_domainWideningKeepsCoveredSubdomainAssets
    • test_domainPageMoveWithinSubtreeKeepsDataProduct
    • test_hardDeletingSubdomainDetachesParentDomainDataProduct
    • test_hardDeletingSubdomainKeepsDataProductTheContainerStillMatches
    • test_forgedDomainFqnCannotBypassTheDomainRule
  • Not run locally. The focused plan (make java_affected ARGS="--scope focused") selects RuleEngineTest (unit) and DataProductResourceIT (mysql-elasticsearch, parallel). The unit test ran, as above. The IT is left for the merge queue; it compiles (test-compile OK).

Local Java test run: PASSED (unit only)

  • Commit: 4e3d4739e5d (base origin/main); the unit runs were on 3a76f7d47d9, whose main code is identical.
  • Scope: focused; merge readiness is not established.
Step Scope Classes Tests Failed Result
unit openmetadata-service 5 104 0 passed
integration DataProductResourceIT · mysql-elasticsearch · parallel 1 — — not run locally (merge queue)

Ingestion integration tests

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not run. The impacted specs (make playwright_affected) need a running stack; the merge queue runs the full suite. The two pickers are covered by Jest on the query shape only. No Playwright spec checks that a subdomain asset appears in Add Assets.

Manual testing performed

Not performed against a running stack. Repro for reviewers:

  1. Turn on Settings → Preferences → Data Asset Rules → Data Product Domain Validation.
  2. Create DomainA → DomainA.SubB → DomainA.SubB.SubC. Assign a table to SubC.
  3. Create a data product under DomainA, then open Assets → Add Assets. The SubC table is listed and can be added.
  4. On the table's page, the data-product selector lists the DomainA data product.

UI screen recording:

Not applicable: this is a bug fix (picker query scope plus backend rule), not a UI feature.

Checklist:

  • I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.

  • 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: not applicable (no schema change).

  • For a UI feature or feature task: not applicable (bug fix, explained above).

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Reviewed SHA 3a76f7d47d9, the sixth pass. 4e3d4739e5d only tightens the forged-FQN IT assertion, as that review suggested.
    • The first five passes raised 🔴s, all fixed:
      • a move left subdomain assets in two domains;
      • a decision record was missing;
      • domain-lineage removal ran for domains an asset never held;
      • a widening move flattened covered subdomains;
      • hard delete missed inheriting descendants, then judged assets by their own domains only;
      • the rule trusted a request-body FQN;
      • search kept inherited old subdomains after a move.
    • Placement: the inputs are entity PUT/PATCH/CSV and MCP writes, bulk Add Assets, Domain-page asset moves and dry runs, data-product domain changes and domain hard deletes. The outputs are the stored domain and data-product edges, the search index, and the two UI pickers.
    • Trade-off: the review found the author's weighing holds. The extra lookups run only on non-exact matches, move planning only when there are old subdomains, and the delete reconcile only with a surviving ancestor data product.
    • Recommendation: approve. 🟡s answered instead of fixed:
      • The subdomain-delete walk scales with the domain, not the data product: it is gated as above and runs only on an admin delete.
      • Widening re-homes assets held in the old domain itself: this keeps main's "assets follow the data product's domain" behavior. Only subdomain assets are kept.
      • conflictingDataProducts looks up FQNs per asset on a non-exact match: that is at most one query per non-matching data product. An earlier pass preferred that to an unconditional prefetch.
  • Decision check: adds docs/decisions/2026-11-30-a-data-product-accepts-assets-from-its-domain-subtree.md.

  • I have added a test that covers the exact scenario we are fixing.

🤖 Generated with Claude Code

…domain

With Data Product Domain Validation enabled, a data product accepted only assets
assigned directly to its own domain, while the domain's Assets tab counts the
whole subtree. The rule (LogicOps), its reconcile mirror (DataProductRepository
conflicts) and both UI pickers now treat a subdomain at any depth as within the
data product's domain.
…main is deleted

Moving a data product's domain now removes its assets from the old domains'
whole subtree, and hard-deleting a domain detaches data products its assets no
longer match. Adds regression ITs and the decision record.
… domain delete

A data product's domain move now leaves assets in subdomains the new domains
still cover, and removes each re-homed asset only from the subdomains it holds,
so no other asset's domain lineage changes. Hard-deleting a domain also
reconciles descendants that inherit it. The subdomain check reuses FQNs the
caller already holds and resolves the rest once per reconcile chunk.
…t move

Coverage now also uses an asset's inherited domain, so a table under a schema in
a still-covered subdomain keeps inheriting it instead of being pinned to the new
domain. The Domain-page conflict check prefetches FQNs once; adds ITs for the
inherited and Domain-page cases.
…its edges go

Hard-deleting a domain now captures its direct assets before the edges are
removed and reconciles them in postDelete with the inheritance-aware detach, so
an asset that now inherits a matching domain keeps its data product. The work
runs only when a surviving ancestor domain holds a data product.
…m search on a move

The domain rule now resolves the asset's domain FQNs by id instead of trusting
the request body. A data product move also drops inherited old subdomains from
the re-homed assets' search documents, skips the subdomain work when there is
none, and the deleted-domain reconcile runs when the delete lifecycle closes so
its per-thread entry is always cleared.
@karanh37
karanh37 requested review from a team as code owners November 30, 2026 08:47
@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.

# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/DataProductRepository.java
@gitar-bot

gitar-bot Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk

Changing domain validation and move/delete reconciliation alters stored asset–data-product links; errors could leave assignments inconsistent with an asset’s effective domains.

Data products with Data Product Domain Validation enabled now accept assets from their domain and any subdomain at any depth, and domain moves and deletes keep subtree assets consistent. No open 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

@karanh37 karanh37 added the To release Will cherry-pick this PR into the release branch label Dec 1, 2026
@karanh37
karanh37 merged commit 133f91a into main Dec 1, 2026
52 of 53 checks passed
@karanh37
karanh37 deleted the karanh37/issue-37376 branch December 1, 2026 12:58
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

gh-bot-collate Bot commented Dec 1, 2026

Copy link
Copy Markdown

🤖 Not backported to 2.0. Claude looked at the conflict and declined to resolve it:

Backport aborted: PR #39252 onto 2.0

Reason

PR #39252 ("Let data products take assets from subdomains of their domain")
is an incremental enhancement to the Data Product Domain Validation rule
and its reconciliation machinery in DataProductRepository /
DomainRepository. That underlying feature — the
validateDataProductDomainMatch rule, LineageDomainCoordinator,
LineageDomainRollups, the domain-move/domain-delete reconciliation paths,
InheritedFieldEntitySearch, etc. — does not exist on 2.0 at all.

Evidence: diffing each conflicted backend file against its state on main
immediately before this PR (commit 133f91a6158372a6e6e4a99817d968d5b55fdd65^)
shows the gap predates this PR by a wide margin:

File Lines different from 2.0 (pre-PR main state)
DataProductRepository.java 900 insertions / 464 deletions
DomainRepository.java 248 insertions / 177 deletions
DataProductResourceIT.java 453 insertions / 73 deletions

The conflict markers in DataProductRepository.java confirm this directly:
the first hunk's 2.0 side is empty where main already has constants like
DATA_PRODUCT_DOMAIN_MATCH_OPERATION, NOT_A_DATA_PRODUCT_ASSET, and
PORT_FIELDS_BY_NAME — none of which exist anywhere else in 2.0's copy of
the file either. Those were added by earlier, separate PRs that were never
backported to 2.0.

Porting PR #39252 alone onto 2.0 would mean re-implementing (or
back-filling) that entire prior feature first — which is explicitly out of
scope for a single-PR backport ("port this change and nothing else"). There
is no coherent, isolated way to apply "treat subdomains as within a data
product's domain" when the domain-validation rule, its reconciliation paths,
and the ports plumbing it hooks into aren't present to begin with.

What was checked

  • LogicOps.java and RuleEngineTest.java cherry-picked cleanly (no
    conflict) — but this is misleading: they apply cleanly only because 2.0
    already carries an older, divergent shape of the domain rule, so the
    isolated diff happens to still parse. Keeping only that hunk while
    abandoning the repository-layer mirror and reconciliation changes would
    split one feature in half and leave the rule and its "mirror" logic
    (DataProductRepository#conflicts) inconsistent with each other.
  • The frontend-only pieces (DomainFilterUtils.ts,
    dataProductAPI.ts/.test.ts, queryFilter.interface.ts) are small and
    would backport in isolation, but they implement UI pickers for the same
    backend validation rule that isn't present — shipping them alone would
    change picker behavior without the server-side enforcement to match it.

Recommendation

Do not backport #39252 to 2.0 until the prerequisite "Data Product Domain
Validation" feature (ports validation, LineageDomainCoordinator,
LineageDomainRollups, the validateDataProductDomainMatch rule, and related
reconciliation paths) has itself been backported. At that point this PR can
be re-attempted as a normal, much smaller cherry-pick.

State left behind

The cherry-pick of 133f91a6158372a6e6e4a99817d968d5b55fdd65 is left
in-progress with unresolved conflict markers, exactly as it was handed off —
no files were edited and no git state (stage/commit/abort) was changed.

resolver run

@gh-bot-collate

gh-bot-collate Bot commented Dec 1, 2026

Copy link
Copy Markdown

🤖 Backport to 2.1 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

sonika-shah added a commit that referenced this pull request Dec 2, 2026
…heir domain (backport 2.1 #39252) (#39470)

* Fixes #37376: Let data products take assets from subdomains of their domain

With Data Product Domain Validation enabled, a data product accepted only assets
assigned directly to its own domain, while the domain's Assets tab counts the
whole subtree. The rule (LogicOps), its reconcile mirror (DataProductRepository
conflicts) and both UI pickers now treat a subdomain at any depth as within the
data product's domain.

(cherry picked from commit c81326e)

* Keep subdomain assets consistent when a data product moves or a subdomain is deleted

Moving a data product's domain now removes its assets from the old domains'
whole subtree, and hard-deleting a domain detaches data products its assets no
longer match. Adds regression ITs and the decision record.

(cherry picked from commit 49058f1)

* Re-home only uncovered assets and reconcile inheriting descendants on domain delete

A data product's domain move now leaves assets in subdomains the new domains
still cover, and removes each re-homed asset only from the subdomains it holds,
so no other asset's domain lineage changes. Hard-deleting a domain also
reconciles descendants that inherit it. The subdomain check reuses FQNs the
caller already holds and resolves the rest once per reconcile chunk.

(cherry picked from commit 492cace)

* Leave assets inheriting a covered subdomain in place on a data product move

Coverage now also uses an asset's inherited domain, so a table under a schema in
a still-covered subdomain keeps inheriting it instead of being pinned to the new
domain. The Domain-page conflict check prefetches FQNs once; adds ITs for the
inherited and Domain-page cases.

(cherry picked from commit 49be4f2)

* Reconcile a deleted domain's assets by their effective domains after its edges go

Hard-deleting a domain now captures its direct assets before the edges are
removed and reconciles them in postDelete with the inheritance-aware detach, so
an asset that now inherits a matching domain keeps its data product. The work
runs only when a surviving ancestor domain holds a data product.

(cherry picked from commit 0ffd6a6)

* Judge asset domains by stored FQNs and clear inherited subdomains from search on a move

The domain rule now resolves the asset's domain FQNs by id instead of trusting
the request body. A data product move also drops inherited old subdomains from
the re-homed assets' search documents, skips the subdomain work when there is
none, and the deleted-domain reconcile runs when the delete lifecycle closes so
its per-thread entry is always cleared.

(cherry picked from commit 3a76f7d)

* Assert the forged-FQN IT is rejected by the domain rule itself

(cherry picked from commit 4e3d473)

* Decrement domain lineage only for the domains a moved asset counted toward

* Keep inherited domain lineage when a data product's domains are cleared

* Expect the SDK's wrapped exception in the forged-FQN IT

---------

Co-authored-by: karanh37 <[email protected]>
sonika-shah added a commit that referenced this pull request Dec 2, 2026
…heir domain (backport 2.0 #39252) (#39473)

* Fixes #37376: Let data products take assets from subdomains of their domain

With Data Product Domain Validation enabled, a data product accepted only assets
assigned directly to its own domain, while the domain's Assets tab counts the
whole subtree. The rule (LogicOps), its reconcile mirror (DataProductRepository
conflicts) and both UI pickers now treat a subdomain at any depth as within the
data product's domain.

(cherry picked from commit c81326e)

* Keep subdomain assets consistent when a data product moves or a subdomain is deleted

Moving a data product's domain now removes its assets from the old domains'
whole subtree, and hard-deleting a domain detaches data products its assets no
longer match. Adds regression ITs and the decision record.

(cherry picked from commit 49058f1)

* Re-home only uncovered assets and reconcile inheriting descendants on domain delete

A data product's domain move now leaves assets in subdomains the new domains
still cover, and removes each re-homed asset only from the subdomains it holds,
so no other asset's domain lineage changes. Hard-deleting a domain also
reconciles descendants that inherit it. The subdomain check reuses FQNs the
caller already holds and resolves the rest once per reconcile chunk.

(cherry picked from commit 492cace)

* Leave assets inheriting a covered subdomain in place on a data product move

Coverage now also uses an asset's inherited domain, so a table under a schema in
a still-covered subdomain keeps inheriting it instead of being pinned to the new
domain. The Domain-page conflict check prefetches FQNs once; adds ITs for the
inherited and Domain-page cases.

(cherry picked from commit 49be4f2)

* Reconcile a deleted domain's assets by their effective domains after its edges go

Hard-deleting a domain now captures its direct assets before the edges are
removed and reconciles them in postDelete with the inheritance-aware detach, so
an asset that now inherits a matching domain keeps its data product. The work
runs only when a surviving ancestor domain holds a data product.

(cherry picked from commit 0ffd6a6)

* Judge asset domains by stored FQNs and clear inherited subdomains from search on a move

The domain rule now resolves the asset's domain FQNs by id instead of trusting
the request body. A data product move also drops inherited old subdomains from
the re-homed assets' search documents, skips the subdomain work when there is
none, and the deleted-domain reconcile runs when the delete lifecycle closes so
its per-thread entry is always cleared.

(cherry picked from commit 3a76f7d)

* Assert the forged-FQN IT is rejected by the domain rule itself

(cherry picked from commit 4e3d473)

* Adapt the subdomain data product backport to 2.0

2.0 lacks pieces the change builds on in main, so this carries the smallest
equivalents:
- RuleEngine.isOperationEnabled, to gate the domain-delete reconcile on the
  "Data Product Domain Validation" rule.
- DomainDAO.listSubtreeIds and EntityUtil.domainAndSubDomainIds, used to find a
  data product's old subdomains on a domain move.
- The data-product conflict helpers the domain-delete reconcile calls, and
  their constants. The data-product domain-change detach that uses them on
  main is a separate change and is not wired in here.
- The deleted domain's assets are reconciled from postDelete, which on 2.0
  runs after the domain's edges are removed; 2.0 has no delete lifecycle hook.
- dataProductRepository() helper in DomainRepository, plus imports.

* Decrement domain lineage only for the domains a moved asset counted toward

* Keep a data product when a Domain page move stays within its domain subtree

* Expect the SDK's wrapped exception in the forged-FQN IT

* Drop assets a failed domain delete captured when the next delete starts

A delete that throws in cleanup() never reaches postDelete, so its captured
assets stayed in the per-thread map. A new top-level domain delete now clears
them before anything is captured; sub-domains of a cascade leave the map alone.

---------

Co-authored-by: karanh37 <[email protected]>
mohityadav766 added a commit that referenced this pull request Dec 2, 2026
…#39589)

EntityServiceBase.update wraps every failure in OpenMetadataException, so
the server's 400 InvalidRequestException is on the cause. The test asserted
the unwrapped type and failed on every parallel lane of the nightly; it was
added in #39252, whose Java IT lanes were skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data Product "Add Assets" picker and domain validation rule ignore subdomain assets

3 participants