You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Clone() does a deep clone of inner map[string]interface{} and mapstr.M values. But if a map is contained in an array then the value is not cloned. For example, if an object like this were Clone()ed then map within array would not be cloned because Clone() does not look inside []interface{}.
One use case is Filebeat's httpjson input. It uses heavily uses Clone() and as a result arrays object's do not behave as expected. It depends on the result of Clone() only containing mapstr.M (and not map[string]interface{}). It needs mapstr.M's implementation of fmt.Stringer that returns json.
As a possible workaround, httpjson has been considering its own deepClone(mapstr.M) mapstr.M (workaround.go.txt) implementation. But I think it would be better if mapstr.M Clone's implementation automatically handled arrays.
I don't think we'd have any opposition to this, feel free to just make this change here.
The only real note for implementation is that much of the test coverage for usage of mapstr.M still lives in Beats (as a consequence of system tests for example). I would recommend creating a Beats branch pointed at the development branch for this change to see if there are any unexpected test failures before merging the change.
Clone()
does a deep clone of innermap[string]interface{}
andmapstr.M
values. But if a map is contained in an array then the value is not cloned. For example, if an object like this wereClone()
ed then map withinarray
would not be cloned becauseClone()
does not look inside[]interface{}
.One use case is Filebeat's httpjson input. It uses heavily uses
Clone()
and as a result arrays object's do not behave as expected. It depends on the result ofClone()
only containingmapstr.M
(and notmap[string]interface{}
). It needsmapstr.M
's implementation offmt.Stringer
that returns json.As a possible workaround, httpjson has been considering its own
deepClone(mapstr.M) mapstr.M
(workaround.go.txt) implementation. But I think it would be better ifmapstr.M Clone
's implementation automatically handled arrays.Relates: elastic/beats#32472
The text was updated successfully, but these errors were encountered: