Skip to content

[2.1] Fixes #38331: Change request preview returns the ops of an ungated descriptive edit (backport 2.1 #38329) - #38954

Open
fmcardoso wants to merge 1 commit into
2.1from
fmcardoso/cr-preview-ops-2.1
Open

fmcardoso wants to merge 1 commit into
2.1from
fmcardoso/cr-preview-ops-2.1

Conversation

@fmcardoso

@fmcardoso fmcardoso commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Backport of #38329 to 2.1.

Source PR #38329
Merge commit b74209e18700f2a758b5b767748d50dbdf1e0026
Method git cherry-pick -x, applied cleanly. No conflicts.

Cherry-pick for the next 2.1 release: the change is not in 2.1.1.

The change touches ApprovalGate, ChangeRequestService, EntityRepository.previewPatchOps, ChangeRequestResourceIT and an ADR under docs/decisions. On main it was adjusted for #38239 (glossary terms that are not Approved are held as pending). 2.1 already has that handling (backport #38511), so the picked change applies as is and no 2.1-specific glossary adjustment was needed.

Checks

  • mvn spotless:apply on openmetadata-service: no changes.
  • mvn package -pl openmetadata-service -am -Dtest='ApprovalGatePreviewOpsTest,ChangeRequestServiceTest,MutationPlannerTest': 71 tests, 0 failures, 0 errors.
  • ChangeRequestResourceIT: not run locally. It needs the Docker services, and the local test stack was left untouched.

Merge order (ships together)

  1. open-metadata/OpenMetadata: this PR
  2. open-metadata/ai-platform: backport of Check version and publish core at main push #2363, https://github.com/open-metadata/ai-platform/pull/2473
  3. open-metadata/openmetadata-collate: backport of Fix KPI Check and ES deletion logic #8797, https://github.com/open-metadata/openmetadata-collate/pull/9021

🤖 Generated with Claude Code

…scriptive edit (#38329)

* Change request preview reports the ops of an edit no workflow gates

POST /v1/changeRequests/preview returned ops only when an approval workflow
would hold the edit. It now also returns them for an edit no workflow holds,
computed by MutationPlanner from the same prepared entity, so a client can
show what a PATCH of descriptive metadata (description, display name, tags,
owners, domains, columns and similar) would change before sending it. An
ungated edit to any other field still gets no ops. requiresApproval and
workflowDefinitionId are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Share the edit preparation between the gated and ungated preview

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Preview a changed description as the PATCH saves it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Leave derived tags out of an ungated preview's ops

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Return an ungated preview's ops only for descriptive fields

An ungated preview now returns no ops when preparing the patch changes a
field outside the descriptive set, and refuses a glossary term that is not
Approved, as the save does. New tests cover a caller without the edit and
tag, owner and column-description previews matching what PATCH saves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Preview a term that is not Approved as the save now holds it

Main now holds such a term as pending instead of refusing it, so the
preview no longer calls the check the save dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit b74209e)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@fmcardoso
fmcardoso requested a review from a team as a code owner November 27, 2026 09:47
@fmcardoso
fmcardoso requested review from TeddyCr and removed request for a team November 27, 2026 09: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:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

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.

// The updater cleans a changed description before saving it; preview the text that is saved.
if (!Objects.equals(updated.getDescription(), original.getDescription())) {
updated.setDescription(
org.openmetadata.service.util.DescriptionSanitizer.sanitize(updated.getDescription()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Quality: Fully-qualified class names used instead of imports

previewPatchOps calls org.openmetadata.service.util.DescriptionSanitizer.sanitize(...) by its full name, and the new IT code does the same with new java.util.ArrayList<>() and new java.util.TreeSet<>(). The repository's Java rules say to import the class rather than spell out its full name. Spotless won't catch this, so it has to be fixed by hand: import DescriptionSanitizer in EntityRepository and ArrayList/TreeSet in ChangeRequestResourceIT.

Add import org.openmetadata.service.util.DescriptionSanitizer; and use the simple name, and do the same for ArrayList/TreeSet in the IT.:

updated.setDescription(DescriptionSanitizer.sanitize(updated.getDescription()));
  • Apply fix

Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findings

Ungated previews now return descriptive mutation ops, changing the change-request API; mismatched planning could show users a diff unlike the saved edit.

Backports the fix for change request previews returning ops for ungated descriptive edits to 2.1, applied cleanly via cherry-pick. Consider replacing fully-qualified class names with imports in EntityRepository.previewPatchOps (DescriptionSanitizer.sanitize) and ChangeRequestResourceIT (java.util.ArrayList, java.util.TreeSet), since Spotless won't catch them.

💡 Quality: Fully-qualified class names used instead of imports

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:5370 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ChangeRequestResourceIT.java:294 📄 openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ChangeRequestResourceIT.java:428

previewPatchOps calls org.openmetadata.service.util.DescriptionSanitizer.sanitize(...) by its full name, and the new IT code does the same with new java.util.ArrayList<>() and new java.util.TreeSet<>(). The repository's Java rules say to import the class rather than spell out its full name. Spotless won't catch this, so it has to be fixed by hand: import DescriptionSanitizer in EntityRepository and ArrayList/TreeSet in ChangeRequestResourceIT.

Add `import org.openmetadata.service.util.DescriptionSanitizer;` and use the simple name, and do the same for ArrayList/TreeSet in the IT.
updated.setDescription(DescriptionSanitizer.sanitize(updated.getDescription()));
🤖 Prompt for agents
Code Review: Backports the fix for change request previews returning ops for ungated descriptive edits to `2.1`, applied cleanly via cherry-pick. Consider replacing fully-qualified class names with imports in `EntityRepository.previewPatchOps` (`DescriptionSanitizer.sanitize`) and `ChangeRequestResourceIT` (`java.util.ArrayList`, `java.util.TreeSet`), since Spotless won't catch them.

1. 💡 Quality: Fully-qualified class names used instead of imports
   Files: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/EntityRepository.java:5370, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ChangeRequestResourceIT.java:294, openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/ChangeRequestResourceIT.java:428

   `previewPatchOps` calls `org.openmetadata.service.util.DescriptionSanitizer.sanitize(...)` by its full name, and the new IT code does the same with `new java.util.ArrayList<>()` and `new java.util.TreeSet<>()`. The repository's Java rules say to import the class rather than spell out its full name. Spotless won't catch this, so it has to be fixed by hand: import `DescriptionSanitizer` in `EntityRepository` and `ArrayList`/`TreeSet` in `ChangeRequestResourceIT`.

   Fix (Add `import org.openmetadata.service.util.DescriptionSanitizer;` and use the simple name, and do the same for ArrayList/TreeSet in the IT.):
   updated.setDescription(DescriptionSanitizer.sanitize(updated.getDescription()));

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

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant