@@ -254,6 +254,8 @@ func findSetLeaves(s GoStruct, orderedMapAsLeaf bool, opts ...DiffOpt) (map[*pat
254254 return
255255 }
256256
257+ isYangPresence := util .IsYangPresence (ni .StructField )
258+
257259 var sp [][]string
258260 if pathOpt != nil && pathOpt .PreferShadowPath {
259261 // Try the shadow-path tag first to see if it exists.
@@ -314,7 +316,9 @@ func findSetLeaves(s GoStruct, orderedMapAsLeaf bool, opts ...DiffOpt) (map[*pat
314316 // treating it as a leaf (since it is assumed to be
315317 // telemetry-atomic in order to preserve ordering of entries).
316318 if (! isOrderedMap || ! orderedMapAsLeaf ) && util .IsValueStructPtr (ni .FieldValue ) {
317- return
319+ if ! isYangPresence {
320+ return
321+ }
318322 }
319323 if isOrderedMap && orderedMap .Len () == 0 {
320324 return
@@ -334,9 +338,17 @@ func findSetLeaves(s GoStruct, orderedMapAsLeaf bool, opts ...DiffOpt) (map[*pat
334338 }
335339 }
336340
337- outs := out .(map [* pathSpec ]interface {})
338- outs [vp ] = ival
339-
341+ // If the current field is tagged as a presence container,
342+ // we set it's value to `nil` instead of returning earlier.
343+ // This is because empty presence containers has a meaning,
344+ // unlike a normal container.
345+ if isYangPresence {
346+ outs := out .(map [* pathSpec ]interface {})
347+ outs [vp ] = nil
348+ } else {
349+ outs := out .(map [* pathSpec ]interface {})
350+ outs [vp ] = ival
351+ }
340352 if isOrderedMap && orderedMapAsLeaf {
341353 // We treat the ordered map as a leaf, so don't
342354 // traverse any descendant elements.
0 commit comments