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

**URL:** <https://discuss.elastic.co/t/type-error-no-implicit-conversion-of-nilclass-into-string-with-null-date/227547>\
**Category:** Logstash\
**Created:** [April 10, 2020, 6:58pm UTC](https://discuss.elastic.co/t/type-error-no-implicit-conversion-of-nilclass-into-string-with-null-date/227547 "2020-04-10T18:58:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattiacareddu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattiacareddu/32/60917_2.png) [@mattiacareddu](https://discuss.elastic.co/u/mattiacareddu)\
**Post date:** [April 10, 2020, 6:58pm UTC](https://discuss.elastic.co/t/type-error-no-implicit-conversion-of-nilclass-into-string-with-null-date/227547/1 "2020-04-10T18:58:16Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 10, 2020, 11:15pm UTC](https://discuss.elastic.co/t/type-error-no-implicit-conversion-of-nilclass-into-string-with-null-date/227547/2 "2020-04-10T23:15:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mattiacareddu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattiacareddu/32/60917_2.png) [@mattiacareddu](https://discuss.elastic.co/u/mattiacareddu)\
**Post date:** [April 11, 2020, 10:00am UTC](https://discuss.elastic.co/t/type-error-no-implicit-conversion-of-nilclass-into-string-with-null-date/227547/3 "2020-04-11T10:00:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 9, 2020, 10:01am UTC](https://discuss.elastic.co/t/type-error-no-implicit-conversion-of-nilclass-into-string-with-null-date/227547/4 "2020-05-09T10:01:58Z")

</div>

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