Type error no implicit conversion of NilClass into String with null date

I'm having the following error when logstash try to index a null value in date field:

Type error no implicit conversion of NilClass into String

This is the complete stacktrace

2458 rufus-scheduler intercepted an error:
job:
Rufus::Scheduler::CronJob "*/1 * * * *" {}
error:
2458
TypeError
no implicit conversion of NilClass into String
uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/date/format.rb:335:in _parse' uri:classloader:/META-INF/jruby.home/lib/ruby/stdlib/date.rb:734:in parse'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.19/lib/logstash/plugin_mixins/jdbc/value_tracking.rb:97:in set_value' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.19/lib/logstash/plugin_mixins/jdbc/jdbc.rb:255:in execute_statement'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.19/lib/logstash/inputs/jdbc.rb:309:in execute_query' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.19/lib/logstash/inputs/jdbc.rb:276:in block in run'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:234:in do_call' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:258:in do_trigger'
/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:300:in block in start_work_thread' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:299:in block in start_work_thread'
org/jruby/RubyKernel.java:1425:in loop' /usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rufus-scheduler-3.0.9/lib/rufus/scheduler/jobs.rb:289:in block in start_work_thread'
tz:
ENV['TZ']:
Time.now: 2020-04-10 18:18:00 UTC
scheduler:
object_id: 2008
opts:
{:max_work_threads=>1}
frequency: 0.3
scheduler_lock: #Rufus::Scheduler::NullLock:0x68aa044b
trigger_lock: #Rufus::Scheduler::NullLock:0x454b18b4
uptime: 177.913122 (2m57s913)
down?: false
threads: 2
thread: #Thread:0x145d4cfc
thread_key: rufus_scheduler_2008
work_threads: 1
active: 1
vacant: 0
max_work_threads: 1
mutexes: {}
jobs: 1
at_jobs: 0
in_jobs: 0
every_jobs: 0
interval_jobs: 0
cron_jobs: 1
running_jobs: 1
work_queue: 0

The filed is mapped in elasticsearch as date type:

"updated_at" : { "type" : "date" }

In logstash I'm using the jdbc plugin so I simply execute the query that could return null value for that field.
I tried to remove the field using this filter

filter {
  if ![updated_at] {
    mutate{
        remove_field => ["updated_at"]
    }
  }
}

but I still get the error.
Any suggestions?

If the jdbc input gets a date/time from the DB it will parse it into a LogStash::Timestamp. It does that way before the filters are applied. Adding a CAST to your SQL so that the database returns a string might fix it.

So I have to CAST it from SQL query, then using logstash filter get it back as date.
And I have to apply it to every nullable date. This seems a crap to me.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.