Skip to content

[2.1] Fixes #35913: remove tags a resolved TagUpdate leaves out - #37720

Merged
yan-3005 merged 1 commit into
2.1from
backport/2.1/pr-36008
Nov 13, 2026
Merged

yan-3005 merged 1 commit into
2.1from
backport/2.1/pr-36008

Conversation

@yan-3005

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #35913

Backport of #36008 to 2.1. A clean cherry-pick of 7f84d27.

When a TagUpdate task is approved, the UI sends newValue = the task's currentTags minus tagsToRemove plus tagsToAdd. The server dropped tagsToRemove and only added. As a result:

  • A Replace inside a mutually exclusive classification left the column unchanged while the task showed Approved: the mutual-exclusivity error was logged and swallowed.
  • A Remove left the removed tag in place.

Now the approved list replaces what the task saw (its currentTags snapshot plus tagsToRemove). Tags added to the target after the task was filed stay, unless an approved tag from the same mutually exclusive classification displaces them. A task without a snapshot only removes its tagsToRemove.

Type of change:

  • Bug fix

Tests:

  • TaskResourceIT#testApproveColumnTag*: 4 ITs that resolve TagUpdate tasks the way the UI does. They cover a Replace within a mutually exclusive classification, a Remove with a tag added after the task, a concurrent swap, and an Add without a snapshot.
  • TaskWorkflowHandlerTest: the 5 unit tests from Fixes #35913: remove tags a resolved TagUpdate leaves out #36008.
  • Results on this branch: TaskWorkflowHandlerTest 31/31; TaskResourceIT#testApproveColumnTag* 4/4 on mysql-elasticsearch and 4/4 on postgres-opensearch; spotless clean.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have added tests around the new logic.

🤖 Generated with Claude Code

* Fixes #35913: remove tags a resolved TagUpdate leaves out

* Keep tags added after the task when a TagUpdate replace is resolved

* Read the TagUpdate snapshot from the action's currentTagsField

* Also drop live tags from the same mutually exclusive classification

* Keep a TagUpdate's other tags when the task has no currentTags snapshot

Resolving with newValue fell back to the target's live tags when the task
carried no currentTags, so an API-filed Add task resolved with newValue
removed every other tag on the column. Without a snapshot, only tagsToRemove
(and a tag a mutually exclusive newValue tag displaces) is removed now.

Move the removal set into tagsReplacedBy and share the reflective tag read
with patchFieldTags. Add TaskResourceIT cases that resolve TagUpdate tasks the
way the UI does: Replace within a mutually exclusive classification, Remove
with a tag added after the task, a concurrent swap, and an Add without a
snapshot.

---------

Co-authored-by: IceS2 <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
Co-authored-by: Ram Narayan Balaji <[email protected]>
(cherry picked from commit 7f84d27)
@yan-3005
yan-3005 requested a review from a team as a code owner November 13, 2026 06:20
@yan-3005
yan-3005 requested review from mohityadav766 and removed request for a team November 13, 2026 06:20
@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.

@yan-3005 yan-3005 added safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch labels Nov 13, 2026
Comment on lines +940 to 949
snapshot = readTagLabels(payloadNode, action.currentTagsField(), "currentTags", null);
}

// A non-empty resolver-supplied newValue is the final desired tag set (reviewer-edited),
// so treat it as a full replace instead of merging with payload's add/remove split.
if (newValue != null && !newValue.isEmpty()) {
List<TagLabel> newTags =
JsonUtils.readValue(newValue, new TypeReference<List<TagLabel>>() {});
if (newTags != null && !newTags.isEmpty()) {
tagsToAdd = newTags;
tagsToRemove = null;
}
EntityFieldPath path = fieldPathOf(task, fieldPath, FieldProperty.TAGS);
List<TagLabel> resolvedTags = readResolvedTags(newValue);
if (!resolvedTags.isEmpty()) {
tagsToRemove =
tagsReplacedBy(resolvedTags, snapshot, tagsToRemove, targetTags(entity, path));
tagsToAdd = resolvedTags;
}

@gitar-bot gitar-bot Bot Nov 13, 2026 •

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: New TagUpdate newValue resolution contract has no decision record

This PR changes what a resolver's newValue means for a TagUpdate. That meaning is a contract the UI (TaskFormSchemaUtils.mergeResolutionTags) and the server both have to follow. Before, the server treated newValue as tags to add. Now it treats newValue as the approved final list, and it replaces the task's currentTags snapshot plus tagsToRemove. The description gives the rule: "the approved list replaces what the task saw (its currentTags snapshot plus tagsToRemove). Tags added to the target after the task was filed stay, unless an approved tag from the same mutually exclusive classification displaces them. A task without a snapshot only removes its tagsToRemove." Nothing in docs/decisions/ records this; a search for TagUpdate, tagsToRemove and currentTags returns nothing. The only place the rule lives is a private Javadoc on tagsReplacedBy. The record should say: "An approved TagUpdate's newValue is the final tag list built from the task's currentTags snapshot. On approval it replaces snapshot ∪ tagsToRemove on the target. Tags added to the target after the task was filed are kept unless a newValue tag of the same mutually exclusive classification displaces them. Without a snapshot, only tagsToRemove is removed. An empty newValue falls back to the payload's tagsToAdd/tagsToRemove." Add that record under docs/decisions/ and cite it as ADR:<date>-<slug> from tagsReplacedBy.

Add docs/decisions/2026-11-xx-tagupdate-newvalue-replaces-the-tasks-snapshot.md stating the rule above, and cite it from tagsReplacedBy.:

/**
 * A resolver's newValue is the final tag list the reviewer approved ... (see
 * ADR:2026-11-xx-tagupdate-newvalue-replaces-the-tasks-snapshot).
 */

Was this helpful? React with 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 🔴 High risk 0 closed / 1 findings

Changing approved TagUpdate resolution to remove snapshot and requested tags while preserving concurrent tags could erase valid column classifications if replacement logic is wrong.

Fixes #35913 by making an approved TagUpdate's newValue the final tag list built from the task's currentTags snapshot, so Replace and Remove resolutions now apply correctly instead of being dropped or swallowed. Changes requested: the new newValue resolution contract in TaskWorkflowHandler has no decision record under docs/decisions/, and one should be added and cited from tagsReplacedBy.

⚠️ Quality: New TagUpdate newValue resolution contract has no decision record

📄 openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java:940-949 📄 openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java:969-983

This PR changes what a resolver's newValue means for a TagUpdate. That meaning is a contract the UI (TaskFormSchemaUtils.mergeResolutionTags) and the server both have to follow. Before, the server treated newValue as tags to add. Now it treats newValue as the approved final list, and it replaces the task's currentTags snapshot plus tagsToRemove. The description gives the rule: "the approved list replaces what the task saw (its currentTags snapshot plus tagsToRemove). Tags added to the target after the task was filed stay, unless an approved tag from the same mutually exclusive classification displaces them. A task without a snapshot only removes its tagsToRemove." Nothing in docs/decisions/ records this; a search for TagUpdate, tagsToRemove and currentTags returns nothing. The only place the rule lives is a private Javadoc on tagsReplacedBy. The record should say: "An approved TagUpdate's newValue is the final tag list built from the task's currentTags snapshot. On approval it replaces snapshot ∪ tagsToRemove on the target. Tags added to the target after the task was filed are kept unless a newValue tag of the same mutually exclusive classification displaces them. Without a snapshot, only tagsToRemove is removed. An empty newValue falls back to the payload's tagsToAdd/tagsToRemove." Add that record under docs/decisions/ and cite it as ADR:<date>-<slug> from tagsReplacedBy.

Add docs/decisions/2026-11-xx-tagupdate-newvalue-replaces-the-tasks-snapshot.md stating the rule above, and cite it from tagsReplacedBy.
/**
 * A resolver's newValue is the final tag list the reviewer approved ... (see
 * ADR:2026-11-xx-tagupdate-newvalue-replaces-the-tasks-snapshot).
 */
🤖 Prompt for agents
Code Review: Fixes #35913 by making an approved TagUpdate's `newValue` the final tag list built from the task's `currentTags` snapshot, so Replace and Remove resolutions now apply correctly instead of being dropped or swallowed. Changes requested: the new `newValue` resolution contract in `TaskWorkflowHandler` has no decision record under `docs/decisions/`, and one should be added and cited from `tagsReplacedBy`.

1. ⚠️ Quality: New TagUpdate newValue resolution contract has no decision record
   Files: openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java:940-949, openmetadata-service/src/main/java/org/openmetadata/service/tasks/TaskWorkflowHandler.java:969-983

   This PR changes what a resolver's `newValue` means for a TagUpdate. That meaning is a contract the UI (`TaskFormSchemaUtils.mergeResolutionTags`) and the server both have to follow. Before, the server treated `newValue` as tags to add. Now it treats `newValue` as the approved final list, and it replaces the task's `currentTags` snapshot plus `tagsToRemove`. The description gives the rule: "the approved list replaces what the task saw (its `currentTags` snapshot plus `tagsToRemove`). Tags added to the target after the task was filed stay, unless an approved tag from the same mutually exclusive classification displaces them. A task without a snapshot only removes its `tagsToRemove`." Nothing in `docs/decisions/` records this; a search for TagUpdate, tagsToRemove and currentTags returns nothing. The only place the rule lives is a private Javadoc on `tagsReplacedBy`. The record should say: *"An approved TagUpdate's newValue is the final tag list built from the task's currentTags snapshot. On approval it replaces snapshot ∪ tagsToRemove on the target. Tags added to the target after the task was filed are kept unless a newValue tag of the same mutually exclusive classification displaces them. Without a snapshot, only tagsToRemove is removed. An empty newValue falls back to the payload's tagsToAdd/tagsToRemove."* Add that record under `docs/decisions/` and cite it as `ADR:<date>-<slug>` from `tagsReplacedBy`.

   Fix (Add docs/decisions/2026-11-xx-tagupdate-newvalue-replaces-the-tasks-snapshot.md stating the rule above, and cite it from tagsReplacedBy.):
   /**
    * A resolver's newValue is the final tag list the reviewer approved ... (see
    * ADR:2026-11-xx-tagupdate-newvalue-replaces-the-tasks-snapshot).
    */

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

@yan-3005
yan-3005 merged commit 53d1553 into 2.1 Nov 13, 2026
54 of 58 checks passed
@yan-3005
yan-3005 deleted the backport/2.1/pr-36008 branch November 13, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants