fix panic when fieldspec refers an empty value

This commit is contained in:
Donny Xia
2020-08-07 10:47:25 -07:00
parent 6afabf26ae
commit a2693d0249
3 changed files with 61 additions and 0 deletions

View File

@@ -467,6 +467,10 @@ func (s FieldSetter) Filter(rn *RNode) (*RNode, error) {
if err := ErrorIfInvalid(rn, yaml.ScalarNode); err != nil {
return rn, err
}
// value is nil or null
if IsMissingOrNull(s.Value) {
return rn, nil
}
// only apply the style if there is not an existing style
// or we want to override it
if !s.OverrideStyle || s.Value.YNode().Style == 0 {