diff --git a/ytypes/node_cache.go b/ytypes/node_cache.go index f1af617a..f7b12aa8 100644 --- a/ytypes/node_cache.go +++ b/ytypes/node_cache.go @@ -123,7 +123,8 @@ func (c *NodeCache) set(path *gpb.Path, val interface{}, opts ...SetNodeOpt) (se } // Set value in the config tree. - if (*schema).Parent != nil && (*schema).Parent.IsContainer() { + // Condition: not a node or the parent is a container. + if val.(*gpb.TypedValue).GetJsonIetfVal() == nil || ((*schema).Parent != nil && (*schema).Parent.IsContainer()) { var encoding Encoding var options []UnmarshalOpt if hasSetNodePreferShadowPath(opts) {