Issues

Select view

Select search mode

 
50 of

undefined method `flat_map' for nil:NilClass when conditional on an output

Fixed

Description

Using the following config + the latest code as of 9/19/14, this error is thrown when the output receives an event:

(eval):22:in `block in initialize': undefined method `flat_map' for nil:NilClass (NoMethodError)
from /media/truecrypt1/git/danielredoak/logstash/lib/logstash/pipeline.rb:272:in `call'
from /media/truecrypt1/git/danielredoak/logstash/lib/logstash/pipeline.rb:272:in `output'
from /media/truecrypt1/git/danielredoak/logstash/lib/logstash/pipeline.rb:231:in `outputworker'
from /media/truecrypt1/git/danielredoak/logstash/lib/logstash/pipeline.rb:160:in `block in start_outputs'

Config Ex:

input { file { path => "somefile" } } output { if [type] == "test" { stdout{} } file { path => "someoutput" } }

Related file, code starts at 328:
https://github.com/elasticsearch/logstash/blob/4211522de1cf996891c6b93f93ba1ab4e408d587/lib/logstash/config/config_ast.rb#L328

Web links

Gliffy Diagrams

Details

Assignee

Reporter

Fix versions

Affects versions

Created September 19, 2014 at 6:08 PM
Updated September 23, 2014 at 2:38 PM
Resolved September 23, 2014 at 2:38 PM

Activity

Show:

Colin Surprenant September 23, 2014 at 2:37 PM

merged in master!

Colin Surprenant September 23, 2014 at 12:51 PM

Confirmed. Thanks for the report! See https://github.com/elasticsearch/logstash/pull/1768

Will be merged in master shortly!

Ryan O'Keeffe September 19, 2014 at 6:21 PM
Edited

Looks like its related to the events local var not being set initially for the output_func in the compiled config.

http://pastebin.com/JJRWqi26

Related code starts at line 73: https://github.com/elasticsearch/logstash/blob/master/lib/logstash/config/config_ast.rb#L73

Perhaps the fix is to change this line to include "output" as well (or remove the conditional around it) but I don't have the experience with this code to really know for sure at this point. https://github.com/elasticsearch/logstash/blob/master/lib/logstash/config/config_ast.rb#L77-L79

["filter", "output"].each do |type| # defines @filter_func and @output_func definitions << "@#{type}_func = lambda do |event, &block|" if type == "filter" definitions << " events = [event]" end ...

to

["filter", "output"].each do |type| # defines @filter_func and @output_func definitions << "@#{type}_func = lambda do |event, &block|" definitions << " events = [event]" ...