Repository navigation
Description
Detail Bug Report
Introduced in #25894 by @harshach on Apr 23, 2026
Summary
- Context:
FieldPathUtilsresolves a caller-supplied field path (e.g.columns::street::description) to a child POJO on an entity (Table, Topic, Container, APIEndpoint, …) so thatTaskWorkflowHandlercan apply a description/tag suggestion by mutating the right field and generating a JSON patch. - Bug: When a leaf name (e.g.
street) appears as a child inside two different sibling subtrees,setDescriptionInList/getDescriptionFromList/findFieldInListrecurse into the first sibling'schildren, write/return the first match found in DFS order, and report success — theisAmbiguousguard only inspects the current list, so the duplicate living one level deeper is invisible to it. - Actual vs. expected: A description/tag suggestion addressing a bare leaf name shared by two nested fields silently overwrites whichever sibling's child is iterated first, leaves the intended field untouched, persists the patch, and reports success — instead of refusing to guess (the explicitly stated contract: "guessing is worse than declining").
- Impact: Wrong-target write of a caller-supplied description (or wrong-target tag resolution) within an entity the caller is already authorized to edit, with a false success return. Reachable only via a hand-crafted task payload; no shipped UI or migration flow emits a bare-leaf nested path.
Code with Bug
openmetadata-service/src/main/java/org/openmetadata/service/util/FieldPathUtils.java
private static boolean setDescriptionInList(
List<?> fieldList, String fieldName, String description) {
// Before any match: an ambiguous name must not be resolved by position, and must not fall
// through to the nested/recursive branches below either, which would write to a grandchild.
if (isAmbiguous(fieldList, fieldName)) { // <-- BUG 🔴 only checks duplicates in the current list
return false;
}
// Try exact match first
Optional<?> field = findFieldByName(fieldList, fieldName);
if (field.isPresent()) {
return setDescription(field.get(), description);
}
// Handle nested path (e.g., "parent.child")
if (fieldName.contains(".")) { … }
// Search recursively in children
for (Object item : fieldList) {
List<?> children = getFieldListFromObject(item, "children");
if (children != null && !children.isEmpty()) {
if (setDescriptionInList(children, fieldName, description)) { // <-- BUG 🔴 stops at first subtree match
return true;
}
}
}
return false;
}isAmbiguous only counts matches in the current list:
private static boolean isAmbiguous(List<?> fieldList, String name) {
int matches = 0;
for (Object item : fieldList) {
if (name.equals(ChildFieldResolver.invokeGetter(item, "getName"))) {
matches++;
}
}
return matches > 1;
}Explanation
- The ambiguity guard (
isAmbiguous) prevents resolving duplicates only when duplicates exist in the same list. If duplicates exist one level deeper (e.g., two siblings each have a child namedstreet),isAmbiguous([profile,address], "street")returns false. - After failing to find
streetat the current level, each ofsetDescriptionInList,getDescriptionFromList, andfindFieldInListperforms a depth-first recursive search and returns on the first nested match. This means:updateFieldDescription(..., "columns::street::description", ...)mutates the first sibling’s matching grandchild and returnstrue, persisting a patch for the wrong target.getFieldDescription(..., "columns::street::description")returns the first sibling’s value.findField(..., "columns::street::tags")returns the first sibling’s child POJO.
Codebase Inconsistency
- The code comments and later guard addition explicitly claim ambiguous names must not fall through into the recursive branch, but the implementation only checks ambiguity at the current list level; cross-subtree duplicates still fall through and are resolved by iteration order.
Failing Test
A reproducer test confirms the buggy behavior (it passes because it asserts the incorrect behavior):
openmetadata-service/src/test/java/org/openmetadata/service/util/FieldPathAmbigReproTest.java
package org.openmetadata.service.util;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import jakarta.json.JsonPatch;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import org.junit.jupiter.api.Test;
import org.openmetadata.schema.entity.data.Table;
import org.openmetadata.schema.type.Column;
import org.openmetadata.service.jdbi3.EntityRepository;
class FieldPathAmbigReproTest {
/** Table with columns [profile, address], each with a child named "street". */
private static Table twinStreetTable() {
Column profileStreet = new Column().withName("street"); // description null
Column profile = new Column().withName("profile").withChildren(new ArrayList<>(List.of(profileStreet)));
Column addressStreet = new Column().withName("street").withDescription(null); // description null
Column address = new Column().withName("address").withChildren(new ArrayList<>(List.of(addressStreet)));
return new Table()
.withId(UUID.randomUUID())
.withName("people")
.withColumns(new ArrayList<>(List.of(profile, address)));
}
@Test
void updateFieldDescription_bareLeafAfterTwoSubtrees_writesFirstSibling() {
Table table = twinStreetTable();
EntityRepository<?> repository = mock(EntityRepository.class);
boolean updated =
FieldPathUtils.updateFieldDescription(
table, repository, "admin", "columns::street::description", "Road name");
// BUG: returns true (reports success) instead of refusing the ambiguous name.
assertTrue(updated, "updateFieldDescription reported failure; expected the bug to report success");
Column profileStreet = table.getColumns().get(0).getChildren().get(0); // "street" under "profile"
Column addressStreet = table.getColumns().get(1).getChildren().get(0); // "street" under "address"
// BUG: the description landed on the FIRST sibling's child only.
assertEquals("Road name", profileStreet.getDescription(), "profile.street should have been written");
assertNull(addressStreet.getDescription(), "address.street should have been left untouched");
// repository.patch was called once — the wrong-target write was persisted.
verify(repository)
.patch(isNull(), eq(table.getId()), eq("admin"), any(JsonPatch.class), isNull(), isNull());
}
@Test
void getFieldDescription_bareLeafAfterTwoSubtrees_returnsFirstSibling() {
Table table = twinStreetTable();
// Seed the two siblings' street columns with distinguishable descriptions.
table.getColumns().get(0).getChildren().get(0).setDescription("first");
table.getColumns().get(1).getChildren().get(0).setDescription("second");
Optional<String> description =
FieldPathUtils.getFieldDescription(table, "columns::street::description");
// BUG: returns the FIRST sibling's child's description, indistinguishable from a unique match.
assertTrue(description.isPresent());
assertEquals("first", description.get());
assertNotEquals("second", description.get());
}
@Test
void findField_bareLeafAfterTwoSubtrees_returnsFirstSibling() {
Table table = twinStreetTable();
Optional<Object> found = FieldPathUtils.findField(table, "columns::street::tags");
// BUG: returns the FIRST sibling's child POJO, indistinguishable from a unique match.
assertTrue(found.isPresent(), "findField should resolve the first sibling's street");
Column resolved = (Column) found.get();
assertEquals("street", resolved.getName());
assertSame(
table.getColumns().get(0).getChildren().get(0),
resolved,
"findField resolved a Column that is not the first sibling's (profile) street");
assertNotSame(
table.getColumns().get(1).getChildren().get(0),
resolved,
"findField should NOT have resolved the second sibling's (address) street");
}
}Test output:
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[FieldPathUtils] Updated description at 'columns::street::description' in entity 'people'
BUILD SUCCESS
Recommended Fix
Make the recursive branch detect duplicates across sibling subtrees (do not short-circuit on the first nested match). For example, scan all immediate children lists for matches and refuse if more than one hit exists, and apply the same logic to setDescriptionInList, getDescriptionFromList, and findFieldInList.
History
This bug was introduced in commit 51ecf45. The "Task redesign" PR (#25894) created FieldPathUtils.java with setDescriptionInList and getDescriptionFromList, both ending in a "Search recursively in children" loop that short-circuits on the first subtree whose children contain the target name and reports success — so a bare leaf name shared by two sibling subtrees silently writes to whichever sibling is iterated first. findFieldInList was added later by addc1cd3b4 with the identical recursive first-match shape. The isAmbiguous guard added by 179fab04655 (#34182) later partially fixed the same-list ambiguity case but left the cross-subtree case untouched, despite an explicit comment claiming the recursive branch was covered; since that change reduced rather than increased severity, the origin remains the original Task redesign commit.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✅
Activity
Fixes open-metadata#34450: refuse ambiguous nested fieldPath instead …