-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #7998: ignore event fields that contains a nil interface of type encoding.TextMarshaler #7999
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
jenkins test this |
fffd619
to
ff146e8
Compare
ff146e8
to
751ac99
Compare
@@ -158,6 +158,9 @@ func normalizeValue(value interface{}, keys ...string) (interface{}, []error) { | |||
|
|||
switch value.(type) { | |||
case encoding.TextMarshaler: | |||
if reflect.ValueOf(value).Kind() == reflect.Ptr && reflect.ValueOf(value).IsNil() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to do this check up on line 135 where we check for plain old nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Value may be either a nil interface of an interface storing a nil pointer :)
when running the libbeat TestNormalizeValue
unit tests:
- the check for
value == nil
at line 135 protects against the test{nil, nil}
- the check for stored nil pointers that I added at line 161 protects against
{nilTimePtr, nil}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but should we do this check immediately upon entering normalizeValue
so that we drop all interfaces storing nil pointers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andrewkroh: I didn't want to add a run-time check for all fields in the event map.
The 2 cases where the interface{}
can store a pointer to a nil value are encoding.TextMarshaler
and followPointer
. And followPointer
already checks for nil pointer
If you prefer, I can move the test to the beginning of the function normalizeValue
.
It could be safer if a new encoder case is added later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to add a run-time check for all fields in the event map.
I suspected that might be a reason for not doing it at method entry.
jenkins test this |
Fix #7998: ignore event fields that contains a nil interface of type encoding.TextMarshaler