Empty events set for failed xpath
inammathe opened this issue · 1 comments
inammathe commented
This bug was introduced in #57
The issue it creates is for failed xpath queries e.g.
xml {
source => "xmldata"
target => "data"
xpath => [ "//foo/text()","xpath_field" ]
}
<foobar>
some text
</foobar>
Will result in empty []
fields being set in elastic.
This is due to the data
variable being initialized and set outside of the normalized_nodeset
loop with no condition for empty/nil value setting.
See below -
logstash-filter-xml/lib/logstash/filters/xml.rb
Lines 159 to 177 in d5157e2
I propose #59 to address this issue by simply appending an unless data.nil? || data.empty?
condition to the set operation. See - https://github.com/logstash-plugins/logstash-filter-xml/pull/59/files#diff-46633c67f32820575bd30a6a35b252c7R176