Skip to content

Fixes #38343: CheckChangeDescription governance rules trigger for sparse entity-reference changes - #38380

Merged
yan-3005 merged 5 commits into
mainfrom
detail/bug-fix/fixes-38343-checkchangedescription-governance-rule-716f4f
Nov 23, 2026
Merged

yan-3005 merged 5 commits into
mainfrom
detail/bug-fix/fixes-38343-checkchangedescription-governance-rule-716f4f

Conversation

@detail-app

@detail-app detail-app Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Detail bug report: View on Detail

Describe your changes:

Fixes #38343

I worked on governance workflow CheckChangeDescriptionTaskImpl silently bypassing its rules when a changed field's new value is a schema-valid but "sparse" EntityReference, because the EntityReference schema only requires id + type and FieldChangeValueExtractor could not extract a matchable value from it. This let restricted changes (e.g. defaultPersona on a Team or User) pass through unvalidated for any API/SDK client sending {id, type} only. A LOG.debug was the only trace, so the bypass was invisible in tests and logs.

Type of change:

  • Bug fix

High-level design:

N/A — small change.

Tests:

Use cases covered

  • A governance CheckChangeDescription rule keyed on a field whose new value is a sparse EntityReference ({id, type} only) now matches instead of being silently skipped, because FieldChangeValueExtractor falls back to the (typically fully-populated) oldValue when the newValue yields no fullyQualifiedName/tagFQN.
  • PATCH /v1/teams/{id} that sets defaultPersona to a sparse ref now records a fully-populated reference (carrying fullyQualifiedName) in ChangeDescription, mirroring the existing validateDefaultDomain pattern on User. PUT was already correct via TeamMapper.
  • PATCH/PUT on a User that sets defaultPersona now hydrates the reference via a new validateDefaultPersona(user) in UserRepository.prepare, mirroring validateDefaultDomain; the recorded change carries the FQN, and the system-default-persona detection (which only needs getId(), preserved) is unchanged.
  • A genuinely unextractable value (both newValue and oldValue lack any FQN) is still skipped, but now logs at WARN (not DEBUG) so the misconfiguration/unsupported shape is not invisible.

Unit tests

  • Added 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); null new value with populated old value still resolves (no regression); both sparse → null; the extractFqnFromValue paths for plain strings, JSON-object strings, fullyQualifiedName/tagFQN maps, lists of populated and sparse maps, mixed lists, and invalid JSON.
  • Existing governance-workflow unit tests pass unchanged: CheckChangeDescriptionTaskImplTest (8), BatchModeNodesTest (17), ChangePreviewUtilsTest (52).

Backend integration tests

  • Added 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 stored defaultPersona carries a fullyQualifiedName equal to the persona's FQN. Plus a patch(OpenMetadataClient, ...) overload. This guards the producer-side hydration (the structural fix) end-to-end.
  • Ran the full TeamDefaultPersonaIT (36 tests, includes the new one), PersonaResourceIT (216 tests), WorkflowDefinitionResourceIT#test_CheckChangeDescriptionTask (the existing end-to-end rule-trigger flow), and the related defaultPersona/defaultDomain regression sweep (ActivePersonaHeaderIT, BotImpersonationIT, MultiTeamUserFanOutIT, TeamHierarchyInheritanceIT, DocStoreResourceIT, 58 tests) — all pass.
  • Ran UserResourceIT in full; all defaultPersona/defaultDomain tests 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

  • Not applicable (no ingestion changes).

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  • Used the affected-test planner make java_affected ARGS="--scope focused" to confirm the diff's impacted scope: it selects CheckChangeDescriptionTaskImplTest, FieldChangeValueExtractorTest (unit) and TeamDefaultPersonaIT (integration, parallel lane, mysql-elasticsearch). All pass.
  • Ran the integration tests via Testcontainers (MySQL + Elasticsearch) with the in-JVM Dropwizard server; the new IT case asserts the FQN end-to-end.

UI screen recording:

Not applicable — backend-only change, no UI behavior touched.

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. (N/A — no schema changes.)
  • 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). (N/A — 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 (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.
  • Decision check: if this PR decides something the next contributor could undo — a schema field, REST path or format another component or repo must agree with, a new default or limit, an ordering that must hold, or a rule stated only in this description — it adds a record under docs/decisions/ (see its README.md). (No durable, cross-component decisions; the extractor's newValue-then-oldValue fallback is internal to governance-workflow rule matching and the validateDefaultPersona hydration mirrors the established validateDefaultDomain pattern.)

Automatic Fixes PRs can be configured here.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no blocking issue was found.

Summary

The PR fills in sparse defaultPersona references before Team and User changes are recorded.

  • Team and User persona changes now carry full names into governance rules.

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

@detail-app
detail-app Bot requested a review from a team as a code owner November 21, 2026 04:05
@detail-app
detail-app Bot requested review from IceS2 and yan-3005 November 21, 2026 04:05
detail-app Bot and others added 3 commits November 21, 2026 05:57
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.
@yan-3005 yan-3005 added the To release Will cherry-pick this PR into the release branch label Nov 23, 2026
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.
@yan-3005

Copy link
Copy Markdown
Contributor

Verified locally (MySQL + Elasticsearch) and trimmed in 904436a:

  • TeamDefaultPersonaIT.test_sparseRefPatchIsHydratedWithFullyQualifiedName fails on main, so the bug is real.
  • With only the TeamRepository/UserRepository hydration (FieldChangeValueExtractor and CheckChangeDescriptionTaskImpl reverted to main): TeamDefaultPersonaIT 38/38 pass. The recorded ChangeDescription now carries the persona's fullyQualifiedName, so the existing new-value match triggers the rule.
  • So I dropped the old-value fallback. It made a rule match the value a field was changed from whenever the new value was sparse, a semantic change beyond this bug. I also dropped the debug→WARN bump, along with the 5 unit cases that asserted the fallback. FieldChangeValueExtractorTest (27) and CheckChangeDescriptionTaskImplTest (8) pass.

@yan-3005 yan-3005 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.

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

@yan-3005
yan-3005 enabled auto-merge (squash) November 23, 2026 15:51
@yan-3005
yan-3005 merged commit 27cc0b0 into main Nov 23, 2026
55 checks passed
@yan-3005
yan-3005 deleted the detail/bug-fix/fixes-38343-checkchangedescription-governance-rule-716f4f branch November 23, 2026 16:10
@github-actions

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

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

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #38514 (clean cherry-pick). It merges itself once the checks pass.

@gh-bot-collate

Copy link
Copy Markdown

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

yan-3005 added a commit that referenced this pull request Nov 24, 2026
…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]>
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.

[Detail Bug] Governance: CheckChangeDescription rules don’t trigger for defaultPersona updates sent as sparse entity references

3 participants