-
Notifications
You must be signed in to change notification settings - Fork 46
Description
-
Version: Logstash 6.5.1(logstash-filter-translate-3.2.3)
-
Operating System: Linux
-
Config File (if you have sensitive info, please remove it):
config file like this:input { generator { lines => [ "100", "200", "300" ] count => 1 } } filter { translate { field => "[message]" destination => "[dest]" dictionary_path => "/root/logstash/config/dic.csv" } }
dictionary file:
100,foo 200,bar 300,boo
-
Steps to Reproduce:
An exception is raised if there is a CRLF in the dictionary file.
After downgrading logstash-filter-translate from 3.2.3 to 3.1.0 or replacing CRLF to LF, everything works as expected. -
Logs:
[2019-02-12T16:37:31,073][ERROR][logstash.pipeline ] Error registering plugin {:pipeline_id=>"main", :plugin=>"#LogStash::FilterDelegator:0x466e9904", :error=>"Translate: Unquoted fields do not allow \r or \n (line 1). when loading dictionary file at /etc/logstash/dic.csv", :thread=>"#<Thread:0x3543a170 run>"} -
Details:
https://github.com/logstash-plugins/logstash-filter-translate/blob/master/lib/logstash/filters/dictionary/csv_file.rb#L20
@csv.shift returns this error if line has \r\n as eol. -
Workarounds:
-
replace dictionary file's eol from \r\n to \n
This workarond is no impact to current code. -
strip \r\n
https://github.com/logstash-plugins/logstash-filter-translate/blob/master/lib/logstash/filters/dictionary/csv_file.rb#L19
@io.string = line
⇒ @io.string = line.strip