Repository navigation
Fixes 37053: Data Product Domain Validation with inherited domains and stale data product domain links - #37006
Conversation
❌ 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 |
🔄 Playwright impact map auto-refreshedThis PR touched specs or UI source that changed the source→spec routing map. I regenerated 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 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 |
There was a problem hiding this comment.
🟡 Changes recommended
The new inheritance call overwrites patched notification-template values with the stored relationship, preventing requested additions, changes, or removals from being saved.
3 open issues
What changed in this PR
This PR updates entity PATCH handling so validation rules can see inherited owners and domains, and preserves inherited domains when direct domain assignments are removed.
Changes:
- Resolves inherited fields before evaluating update rules.
- Retains inherited domains in the updated entity when no direct domains remain.
- Adds unit, integration, and browser regression coverage for inherited-field validation and data-product domain matching.
| File | Description |
|---|---|
openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/DataAssetRulesEnabled.spec.ts |
Adds a browser test for editing an asset with an inherited domain and data product. |
openmetadata-service/src/test/java/org/openmetadata/service/rules/RuleEngineTest.java |
Adds domain and ownership rule cases for inherited references. |
openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java |
Resolves inheritance before PATCH validation and preserves inherited domains. |
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java |
Tests inherited-domain updates, mismatched products, and direct-domain removal. |
Review effort: Balanced
| try (var ignored = phase("patchInheritance")) { | ||
| // Inheritance ran when original was loaded, not on the patched copy: a patch that removes | ||
| // the direct owners or domains must leave the inherited ones visible to the rules. | ||
| setInheritedFields(updated, new Fields(allowedFields, "owners,domains", true)); |
There was a problem hiding this comment.
Fixed in 51081a6: inheritance now runs on a copy, so EventSubscriptionRepository.setInheritedFields can no longer reload the stored template onto the patched alert. EventSubscriptionResourceIT#test_updateSubscriptionAddTemplate / #test_updateSubscriptionChangeTemplate pass.
| // productDomain is rejected by the rule. | ||
| const rejectedDomainTable = new TableClass(); | ||
| // Domain comes only from its schema; carries a Data Product of that domain. | ||
| const inheritedDomainTable = new TableClass(); |
There was a problem hiding this comment.
Fixed in 00e928c: the inherited-domain table owns its service (new TableClass({ service: new DatabaseServiceClass() })), so patching its schema's domain leaves the shared fixtures alone and cleanup deletes the owned chain.
| .thenReturn(List.of()); | ||
| when(relationshipRepository.getEntityReferences( | ||
| org.mockito.ArgumentMatchers.anyList(), org.mockito.ArgumentMatchers.any())) | ||
| .thenReturn(List.of(domain.withInherited(null))); |
There was a problem hiding this comment.
Fixed in 00e928c: the relationship mock returns a separate domain reference, so the facts' domain stays inherited=true.
| await inheritedDomainTable.visitEntityPage(page); | ||
|
|
||
| const description = `edited with inherited domain ${Date.now()}`; | ||
| await updateDescription(page, description, false, undefined, 'tables'); |
There was a problem hiding this comment.
Fixed in 00e928c: passes EntityTypeEndpoint.Table; tsc:playwright is clean.
…llback A tag-only patch on a table that inherits its domain keeps the data product and stores no domain of its own; a patch that also drops the inherited domain still passes Data Product Domain Validation; removing a table's own owner falls back to the schema's owner without storing it or recording it as added.
…ation A data product stores its domains twice: domain HAS dataProduct, read by the API, and domain CONTAINS dataProduct, read by the Data Product Domain Validation rule. Before 1.12.12 / 1.13.1 a domain change rewrote only HAS, so a product moved on those versions still contains its old domain. On 2.0 the rule then rejects every edit to the product's assets, tag-only edits included. The 2.0.9 data migration walks data products in id batches and rewrites CONTAINS to match HAS: it adds the missing links before dropping the stale ones, revives soft-deleted rows, and leaves products without a HAS link alone.
…in the IT A database already at 2.1.0 reprocesses 2.0.9 for its SQL only, so the 2.0.9 step never runs there. 2.1.0 runs the same idempotent repair under its own marker. The IT now asserts the rule rejection message, a second run that changes nothing, and a soft-deleted containment row revived through repairAll.
… patch setInheritedFields on the patched entity reloaded stored state in some repositories: an alert's notification template, which made a template change a silent no-op, and a user's team domains, which stored back a removed own domain the team also gives. The rules now see a copy with inherited owners and domains; the patched entity takes the inherited domains only when it is left with none of its own.
There was a problem hiding this comment.
🟡 Changes recommended
PATCH validation can use a stale notification template and bypass enabled rules, while multi-domain inheritance handling and test isolation also need correction.
7 open issues
Validate PATCH rules against the patched notification template · New Pass the fixture's typed endpoint to updateDescription Preserve patched notificationTemplate when applying inheritance Serialize full-catalog repair tests to prevent race conditions · New Restore removed inherited domains before PATCH validation · New Use an owned schema to isolate the fixture's parent mutation Keep the facts domain inherited in the test fixture
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
PUT validation can use the wrong effective domain, while bulk updates bypass deferred validation entirely, allowing invalid cross-domain data-product assignments to be saved.
7 open issues
Validate omitted domains against the table’s effective PUT domain · New Validate effective domains for existing tables in bulk updates · New Pass the fixture's typed endpoint to updateDescription Preserve patched notificationTemplate when applying inheritance Preserve inherited domains in task PATCH rule facts Use an owned schema to isolate the fixture's parent mutation Keep the facts domain inherited in the test fixture
Review effort: Balanced
| if (!RuleEngine.dependsOnInheritedDomains(entity)) { | ||
| RuleEngine.getInstance().evaluate(entity); | ||
| } |
There was a problem hiding this comment.
Fixed in 0ca99ed: bulkUpdateEntities (the sync and async bulk path for existing entities) runs the same deferred check per item before the updater, so a mismatched item is reported as failed and none of it is saved. DataProductResourceIT#test_bulkPutChecksDataProductsAgainstTheInheritedDomain fails before the change.
A PUT that sends no domains keeps the stored ones, but the deferred check inherited the parent's instead, so a table with its own domain A under a schema in B was checked against B. The deferred PUT check now uses the stored owners and domains, and inherits only when the entity has none of its own. Bulk PUT of existing entities (sync and async) now runs the same per-item check before writing; a failing item is reported and nothing of it is saved.
The bulk PUT loop restored a soft-deleted entity before its deferred rule check, so an item the rules rejected was reported as failed but stayed restored. The check now runs first, as on a single PUT.
There was a problem hiding this comment.
🟡 Changes recommended
Bulk PUT validation can fail after restoring a soft-deleted table and its children without rolling back that restoration, so validation must precede restoration and a regression test must confirm rejected items remain deleted.
7 open issues
Validate bulk PUT before restoring soft-deleted table · New Validate effective domains for existing tables in bulk updates Pass the fixture's typed endpoint to updateDescription Preserve patched notificationTemplate when applying inheritance Preserve inherited domains in task PATCH rule facts Use an owned schema to isolate the fixture's parent mutation Keep the facts domain inherited in the test fixture
1 resolved since last review
Review effort: Balanced
The rule facts dropped the patch's inherited refs and resolved inheritance again, but a task takes its target's domains in prepare and has no inheritance hook, so its domains vanished and a rule requiring one rejected an unrelated PATCH. When inheritance resolves nothing, the facts keep the refs the patched entity already carries.
|
@gitar-bot the bulk PUT restore-order suggestion is fixed in c914cbf: the deferred rule check now runs before the restore, with |
There was a problem hiding this comment.
🟡 Changes recommended
The test overwrites its saved configuration with the temporary tasksNeedADomain rule, so cleanup fails to restore the original settings and can cause order-dependent failures in later tests.
6 open issues
Validate effective domains for existing tables in bulk updates Pass the fixture's typed endpoint to updateDescription Preserve patched notificationTemplate when applying inheritance Restore the original configuration after temporary settings changes · New Use an owned schema to isolate the fixture's parent mutation Keep the facts domain inherited in the test fixture
2 resolved since last review
Review effort: Balanced
The generated with* setters mutate in place, so the test's snapshot picked up the temporary rule and the cleanup reinstalled it. The original settings are now kept as their own JSON copy, restored in finally, and checked to be back.
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · The migration rewrites existing data-product domain links; incorrect reconciliation could mislead validation, rejecting valid asset edits or accepting mismatched products. Fixes Data Product Domain Validation failures on assets with inherited domains by repairing stale data product domain links in the 2.0.9 migration (also run from 2.1.0), evaluating PATCH, create and PUT rules against inherited owners and domains, and checking deferred PUT rules before restoring soft-deleted entities. Resolved this session: the PUT/create path no longer evaluates rules without inherited domains, and the bulk PUT now runs its rule check before restoring a soft-deleted entity, covered by ✅ 2 closed✅ Edge Case: PUT/create path still evaluates rules without inherited domains
✅ Edge Case: Bulk PUT restores a soft-deleted entity before its rules can reject it
VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because parent-reference restoration and approval-gated bulk staging can undermine validation, allowing domain–data-product mismatches to be saved or submitted for approval.
5 open issues
1 resolved since last review
Review effort: Balanced
|
🤖 Backport to |
|
🤖 Backport to |
…nd stale data product domain links (2.0) (#37109) * Fixes #37053: Data Product Domain Validation with inherited domains and stale data product domain links (2.0) Backport of #37006 and #37096 to 2.0. - Rules on PATCH, create, PUT and bulk PUT see the domains an entity inherits from its parent, so an asset whose domain comes from its schema and carries a data product of that domain is no longer rejected. - The 2.0.8 migration rewrites a data product's CONTAINS link to the domain it shows. Products moved to another domain before 1.12.12 / 1.13.1 kept their old domain there, which the rule reads, so every edit to their assets was rejected. The repair walks data products in id batches (IdBatches, ported from main) and only rewrites links that disagree. (cherry picked from commit 16b6974) * chore(playwright): auto-refresh impact-map.generated.json * Stub the containment repair in the 2.0.8 entry-point test The test runs the 2.0.8 data migration against a mocked handle, so the repair step now in that migration needs stubbing like the other steps. --------- Co-authored-by: Sriharsha Chintalapani <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>



Describe your changes:
Fixes #37053
Two causes of
Rule [Data Product Domain Validation] validation failedon updates to an asset whose domain is inherited from its parent and that belongs to a data product.1. Stale data product domain links left by moves before 1.12.12 / 1.13.1 (the 2.0.7 customer report).
A data product stores its domains twice in
entity_relationship:domain HAS dataProduct, which the API and UI read, anddomain CONTAINS dataProduct, which the Data Product Domain Validation rule reads (LogicOps#getDataProductDomains). Before 1.12.12 / 1.13.1, changing a data product's domain rewrote onlyHAS, so a product moved on those versions still contains its old domain. 1.x hid this because the rule then read the product's shown domains. From 2.0 it readsCONTAINS, so after upgrading every edit to that product's assets is rejected, tag-only edits included, even though the UI shows matching domains.This adds a step to the 2.0.9 data migration (MySQL and Postgres) that rewrites
CONTAINSto matchHAS:data_product_entityin keyset id batches (IdBatches, 500 ids), two relationship reads per batch;CONTAINSset differs from its liveHASset, it adds the missingCONTAINSlinks first, then drops the stale ones, so an interrupted run leaves the product in both domains (which the rule accepts), never in neither;insert()upserts onlyjsonand would not revive a soft-deleted row;HASrow (nothing to repair from) and logs every repaired product with its old and new domains;runOncemarker: a database already at 2.1.0 reprocesses 2.0.9 for its SQL only, so its data step would never run there. The repair is a fixed point, so a second run changes nothing.No change to assets is needed: every version that allowed a data product's domain to change also moved its assets (
batchMigrateAssetDomains), so after the repair the rule agrees with where the assets already are. 2.0.x itself keeps both links in sync (#29138; verified that rapid consecutive moves that get consolidated still leaveCONTAINS == HAS), so this only repairs old data.2. A PATCH that drops the asset's own domain is validated without the inherited one.
preparePatchedevaluates the rules on the patched copy before inheritance is reapplied, so a patch that removes the direct domain (or sendsdomains: []alongside a tag change) makes the rule see a data product with no domain. The rules now see a copy of the patched entity with its inherited owners and domains; the patched entity itself takes the inherited domains only when the patch leaves it with none of its own, so it keeps belonging to them in the response and inupdateDataProducts. Inherited refs are still never stored (getEntityReferencesstrips them). Inheritance runs on a copy because some repositories'setInheritedFieldsreload other stored state: on the patched entity it silently undid an alert's notification-template change and stored back a user's removed own domain when a team also gives it.3. Create and PUT checked the rules before the entity inherits. The mapper builds the entity and checks the rules before its parent is attached, so a create or PUT of a table carrying a data product with only an inherited domain was rejected by Data Product Domain Validation, and a PUT update then failed
Domain cannot be empty when data products are provided. Entities with data products and no domain of their own are now checked by the repository once the parent is set, with inherited owners and domains, on create, bulk create, PUT update and bulk PUT (sync and async), against the owners and domains the PUT keeps (a PUT that sends none keeps the stored ones), and the domain guard counts inherited domains. Every other entity keeps the mapper-time check.Type of change:
High-level design:
N/A — a data repair in an existing migration version plus a one-line inheritance step in
preparePatched; no API or schema change.Tests:
Use cases covered
Data Product Domain Validation; after the repair the same PATCH succeeds andCONTAINS == {B}.CONTAINSrow for the shown domain is revived throughrepairAll(the full batched walk).Unit tests
DataProductDomainContainmentRepairTest— 6 cases on the drift/plan logic (DomainLinks).IngestionPipelineMigrationEntryPointTest— asserts 2.1.0 runs the repair on MySQL and Postgres.RuleEngineTest— inherited domains and owners as rule facts, and which entities wait for inheritance (dependsOnInheritedDomains).Backend integration tests
DataProductDomainContainmentMigrationIT(new) — 3 tests.DataProductResourceIT— new tests for the inherited-domain fix (test_updatesToAssetWithInheritedDomainAndDataProductPassDomainValidation,test_dataProductFromAnotherDomainIsStillRejectedOnInheritedDomainAsset,test_dataProductOnTableThatFallsBackToInheritedDomain,test_tagOnlyPatchOnInheritedDomainAssetWithDataProduct,test_tagPatchDroppingInheritedDomainPassesDomainValidation,test_removingDirectOwnerFallsBackToInheritedOwnerWithoutStoringIt);test_dataProductOnTableThatFallsBackToInheritedDomainfails on main without theEntityRepositorychange.UserResourceIT#test_removingOwnDomainAlsoGivenByTeamDropsIt(new) — a user's own domain that a team also gives is dropped by PATCH, not stored back.EventSubscriptionResourceIT#test_updateSubscriptionAddTemplate,#test_updateSubscriptionChangeTemplate— existing; they cover the alert-template path the inheritance step could undo.Local Java test run (commit
136a0cf50f, baseorigin/main, MySQL + Elasticsearch and PostgreSQL + OpenSearch)DataProductDomainContainmentRepairTest,IngestionPipelineMigrationEntryPointTest,MigrationWiringTest,MigrationWorkflowDataMigrationTest,MigrationWorkflowTest,MigrationCodeFingerprintTest,RuleEngineTestSystemResourceITSystemResourceITEvery test this PR adds or changes passes on both engines:
DataProductDomainContainmentMigrationIT(3),DataProductResourceITinherited-domain, create/PUT and bulk PUT tests (11),SystemResourceIT#test_taskPatchKeepsItsTargetsInheritedDomainsForTheRules,UserResourceIT#test_removingOwnDomainAlsoGivenByTeamDropsIt,EventSubscriptionResourceITtemplate tests,IngestionPipelineMigrationEntryPointTest,RuleEngineTest,DataProductDomainContainmentRepairTest.Classes:
TaskResourceIT,DataProductResourceIT,DataProductDomainContainmentMigrationIT,DataProductDomainMigrationIT,DomainResourceIT,DomainBulkAssetsDryRunIT,DomainReassignmentAuthorizationIT,MultiDomainHasDomainIT,TableResourceIT,DatabaseSchemaResourceIT,DatabaseResourceIT,DatabaseServiceResourceIT,UserResourceIT,TeamResourceIT,TeamHierarchyInheritanceIT,IngestionPipelineOwnerInheritanceIT,EventSubscriptionResourceIT,GlossaryTermResourceIT,TagResourceIT, and the migration-area ITs (AlertBacklogMigrationIT,ConnectionSecretsMigrationIT,ConsumerIdMigrationIT,ContextMemoryStatusMigrationIT,ContinuousMigrationIT,CreationAuditMigrationIT,CredentialIndexMigrationIT,CustomSqlDefinitionMigrationIT,DataQualityDimensionMigrationIT,FirstTimeUserMigrationIT,LifeCycleCreatedSentinelMigrationIT,McpGrantMigrationIT,NegatedListRuleMigrationIT,OverrideMetadataRestoreMigrationIT,QuartzTablePurgeMigrationIT,SampleDataStorageMigrationIT,SeedDataPresenceIT,ServiceLineagePipelineRoutingMigrationIT,ThresholdParameterMigrationIT).Verified live: a 1.12.11 PostgreSQL database with a data product moved between domains, upgraded to 2.0.7 (tag PATCH rejected with the reported error), then migrated and served by this branch: both domain links repaired, tag PATCH 200, alert template PATCH kept, a user's own domain also given by a team dropped on PATCH, and removing a table's own domain falls back to the inherited one and keeps the data product.
Ingestion integration tests
Not applicable (no ingestion changes).
Playwright (UI) tests
DataAssetRulesEnabled.spec.ts— editing an asset with an inherited domain and a data product (not run locally; runs in the merge queue).Manual testing performed
Reproduced the customer path end to end with the released Docker images, on MySQL and on PostgreSQL:
openmetadata/server:1.12.11(and separately1.13.0) from the quickstart compose.CONTAINSstayed EXPLOITATION,HASbecame MAINTENANCE. Added the table to the product; a tag PATCH returned 200 on 1.12.11.openmetadata/server:2.0.7: migrations ran clean, the staleCONTAINSsurvived, and a tag-only PATCH on the table returned 400Rule [Data Product Domain Validation] validation failed.CONTAINSto matchHAS(what this migration does): the tag PATCH returned 200, no restart needed.UI screen recording:
Not applicable — backend data migration only.
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 schema change.)
For a UI feature or feature task: as part of PR creation, I ran the PR build in Docker with sample data and embedded a verified GitHub-hosted recording plus build/health evidence above (or explained why this requirement is not applicable). (Not applicable — backend only.)
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.af65144ff3: no 🔴. Fixed: the 2.1.0 rerun (the 2.0.9 step never runs on databases already at 2.1.0); the IT coversrepairAll, soft-deleted revival and a rerun, and asserts the rule message;IngestionPipelineMigrationEntryPointTestasserts 2.1.0 calls the repair.1bc8925341: two 🔴 in thepreparePatchedinheritance step (alert template change undone; user's removed own domain stored back when a team gives it), both fixed in51081a63c5by evaluating the rules on an inherited copy, with tests above.DataProductRepository.setInheritedFieldsreads stored domains for owner inheritance (pre-existing).Decision check: no record needed — this restores an existing invariant (
CONTAINSmirrorsHASfor data product domains) rather than deciding a new one.I have added a test that covers the exact scenario we are fixing.