Skip to content
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

xml filter xpath silent failure #1688

Closed
SleeperSmith opened this issue Sep 3, 2014 · 1 comment
Closed

xml filter xpath silent failure #1688

SleeperSmith opened this issue Sep 3, 2014 · 1 comment

Comments

@SleeperSmith
Copy link

The offending line is at line 93:
begin
doc = Nokogiri::XML(value)
rescue => e
event.tag("_xmlparsefailure")
@logger.warn("Trouble parsing xml", :source => @source, :value => value,
:exception => e, :backtrace => e.backtrace)
return
end

When Nokogiri fails, it does not throw, but instead it puts the error into an "errors" property. So you need to check for doc.errors for parse failures.

This especially problematic in situation where Nokogiri fails to parse but XmlSimple succeeds. Logstash would pump out the log with the structure expanded but none of the xpath would work obviously. (The exact problem i encountered.) The offending character in my case was etc with error message "#<Nokogiri::XML::SyntaxError: Content is not allowed in prolog.>".

P.S. I don't do ruby, so I can't really do a bug fix and pull request.

@jordansissel
Copy link
Contributor

I've moved this here: logstash-plugins/logstash-filter-xml#10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants