diff --git a/libbeat/common/mapstr.go b/libbeat/common/mapstr.go index 7c44e2d5ac3..d70f05dd349 100644 --- a/libbeat/common/mapstr.go +++ b/libbeat/common/mapstr.go @@ -96,10 +96,6 @@ func (m MapStr) deepUpdateMap(d MapStr, overwrite bool) { } func deepUpdateValue(old interface{}, val MapStr, overwrite bool) interface{} { - if old == nil { - return val - } - switch sub := old.(type) { case MapStr: if sub == nil { @@ -117,7 +113,9 @@ func deepUpdateValue(old interface{}, val MapStr, overwrite bool) interface{} { tmp.deepUpdateMap(val, overwrite) return tmp default: - // This should never happen + // We reach the default branch if old is no map or if old == nil. + // In either case we return `val`, such that the old value is completely + // replaced when merging. return val } }