Repository navigation
Fixes #38343: CheckChangeDescription governance rules trigger for sparse entity-reference changes - #38380
Conversation
…rse entity-reference changes
Address greptile review: the GET rebuilds defaultPersona from the stored persona (getDefaultPersona via findTo), so it carries a fullyQualifiedName regardless of the fix. Assert the recorded ChangeDescription's defaultPersona newValue carries a fullyQualifiedName, which is what the fix actually changes and what governance rules match against.
getNewValue() returns Object; the defaultPersona change is recorded as a JSON string via recordChange(..., jsonValue=true), so a direct cast is correct and unblocks compilation of the integration-tests module.
…ption-governance-rule-716f4f
Hydrating defaultPersona in TeamRepository/UserRepository is what fixes the sparse-reference bug: with FieldChangeValueExtractor and CheckChangeDescriptionTaskImpl back to main, TeamDefaultPersonaIT passes 38/38 (and test_sparseRefPatchIsHydratedWithFullyQualifiedName fails on main). The fallback matched a rule against the value a field was changed from whenever the new value was sparse, which changes rule semantics beyond this bug, and the debug-to-WARN bump would log on every unmatched change. Removed both and the five unit cases that asserted the fallback.
|
Verified locally (MySQL + Elasticsearch) and trimmed in 904436a:
|
yan-3005
left a comment
There was a problem hiding this comment.
Verified: TeamDefaultPersonaIT.test_sparseRefPatchIsHydratedWithFullyQualifiedName fails on main and TeamDefaultPersonaIT passes 38/38 with the hydration fix; old-value fallback removed as out of scope (see comment above).
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
…rse entity-reference changes (#38380) (#38514) * Fixes #38343: CheckChangeDescription governance rules trigger for sparse entity-reference changes * test: assert on PATCH ChangeDescription, not GET-hydrated ref Address greptile review: the GET rebuilds defaultPersona from the stored persona (getDefaultPersona via findTo), so it carries a fullyQualifiedName regardless of the fix. Assert the recorded ChangeDescription's defaultPersona newValue carries a fullyQualifiedName, which is what the fix actually changes and what governance rules match against. * fix: cast FieldChange.getNewValue() to String for compile getNewValue() returns Object; the defaultPersona change is recorded as a JSON string via recordChange(..., jsonValue=true), so a direct cast is correct and unblocks compilation of the integration-tests module. * Keep the defaultPersona hydration, drop the old-value fallback Hydrating defaultPersona in TeamRepository/UserRepository is what fixes the sparse-reference bug: with FieldChangeValueExtractor and CheckChangeDescriptionTaskImpl back to main, TeamDefaultPersonaIT passes 38/38 (and test_sparseRefPatchIsHydratedWithFullyQualifiedName fails on main). The fallback matched a rule against the value a field was changed from whenever the new value was sparse, which changes rule semantics beyond this bug, and the debug-to-WARN bump would log on every unmatched change. Removed both and the five unit cases that asserted the fallback. --------- (cherry picked from commit 27cc0b0) Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com> Co-authored-by: Ram Narayan Balaji <[email protected]> Co-authored-by: Ram Narayan Balaji <[email protected]>
Detail bug report: View on Detail
Describe your changes:
Fixes #38343
I worked on governance workflow
CheckChangeDescriptionTaskImplsilently bypassing its rules when a changed field's new value is a schema-valid but "sparse"EntityReference, because theEntityReferenceschema only requiresid+typeandFieldChangeValueExtractorcould not extract a matchable value from it. This let restricted changes (e.g.defaultPersonaon a Team or User) pass through unvalidated for any API/SDK client sending{id, type}only. ALOG.debugwas the only trace, so the bypass was invisible in tests and logs.Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
CheckChangeDescriptionrule keyed on a field whose new value is a sparseEntityReference({id, type}only) now matches instead of being silently skipped, becauseFieldChangeValueExtractorfalls back to the (typically fully-populated)oldValuewhen thenewValueyields nofullyQualifiedName/tagFQN.PATCH /v1/teams/{id}that setsdefaultPersonato a sparse ref now records a fully-populated reference (carryingfullyQualifiedName) inChangeDescription, mirroring the existingvalidateDefaultDomainpattern on User. PUT was already correct viaTeamMapper.PATCH/PUTon a User that setsdefaultPersonanow hydrates the reference via a newvalidateDefaultPersona(user)inUserRepository.prepare, mirroringvalidateDefaultDomain; the recorded change carries the FQN, and the system-default-persona detection (which only needsgetId(), preserved) is unchanged.newValueandoldValuelack any FQN) is still skipped, but now logs atWARN(notDEBUG) so the misconfiguration/unsupported shape is not invisible.Unit tests
openmetadata-service/src/test/java/org/openmetadata/service/governance/workflows/util/FieldChangeValueExtractorTest.java(32 cases) covering: sparse new value with populated old value returns the old FQN (the bug scenario); populated new value takes precedence over old (no regression);nullnew value with populated old value still resolves (no regression); both sparse →null; theextractFqnFromValuepaths for plain strings, JSON-object strings,fullyQualifiedName/tagFQNmaps, lists of populated and sparse maps, mixed lists, and invalid JSON.CheckChangeDescriptionTaskImplTest(8),BatchModeNodesTest(17),ChangePreviewUtilsTest(52).Backend integration tests
TeamDefaultPersonaIT.test_sparseRefPatchIsHydratedWithFullyQualifiedName— sends the exact sparse-ref JSON patch the bug report describes ([{"op":"add","path":"/defaultPersona","value":{"id":"<uuid>","type":"persona"}}]), then asserts the storeddefaultPersonacarries afullyQualifiedNameequal to the persona's FQN. Plus apatch(OpenMetadataClient, ...)overload. This guards the producer-side hydration (the structural fix) end-to-end.TeamDefaultPersonaIT(36 tests, includes the new one),PersonaResourceIT(216 tests),WorkflowDefinitionResourceIT#test_CheckChangeDescriptionTask(the existing end-to-end rule-trigger flow), and the relateddefaultPersona/defaultDomainregression sweep (ActivePersonaHeaderIT,BotImpersonationIT,MultiTeamUserFanOutIT,TeamHierarchyInheritanceIT,DocStoreResourceIT, 58 tests) — all pass.UserResourceITin full; alldefaultPersona/defaultDomaintests pass. The 8 errors observed in the full run are network timeouts/credential-verification 503s under parallel sandbox load (OkHttp call-timeout ~418s) — confirmed non-regressions by re-running the failing tests in isolation (all pass).Ingestion integration tests
Playwright (UI) tests
Manual testing performed
make java_affected ARGS="--scope focused"to confirm the diff's impacted scope: it selectsCheckChangeDescriptionTaskImplTest,FieldChangeValueExtractorTest(unit) andTeamDefaultPersonaIT(integration, parallel lane, mysql-elasticsearch). All pass.UI screen recording:
Not applicable — backend-only change, no UI behavior touched.
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.docs/decisions/(see itsREADME.md). (No durable, cross-component decisions; the extractor'snewValue-then-oldValuefallback is internal to governance-workflow rule matching and thevalidateDefaultPersonahydration mirrors the establishedvalidateDefaultDomainpattern.)Automatic Fixes PRs can be configured here.


Confidence Score: 5/5
The PR appears safe to merge; no blocking issue was found.Summary
The PR fills in sparse
defaultPersonareferences before Team and User changes are recorded.No new actionable issues were found. Tests were not run during this review.
Reviews (5) · Last reviewed commit: "Keep the defaultPersona hydration, drop ..." · Reviewed by Greptile