# Logstash ruby filter condition error

**URL:** <https://discuss.elastic.co/t/logstash-ruby-filter-condition-error/169005>\
**Category:** Logstash\
**Created:** [February 19, 2019, 11:01am UTC](https://discuss.elastic.co/t/logstash-ruby-filter-condition-error/169005 "2019-02-19T11:01:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fadihaddad](https://avatars.discourse-cdn.com/v4/letter/f/4bbf92/32.png) [@fadihaddad](https://discuss.elastic.co/u/fadihaddad)\
**Post date:** [February 19, 2019, 11:01am UTC](https://discuss.elastic.co/t/logstash-ruby-filter-condition-error/169005/1 "2019-02-19T11:01:12Z")

</div>

whenever I added an if condition the code doesn't work on the null offerlist field

here is my filter

```
code => '
      if event.get("offerList") == "NULL"
        t = event.get("UCounter")
        t.each_index { |i|
            t[i]["BUNDLE"] = @dict[t[i]["UCounter_ID"]]
            
        }
        event.set("UCounter", t)
       
       x = event.get("UCounter")
        x.each_index { |i|
            x[i]["DESCRIPTION"] = @dict[x[i]["UCounter_ID"]]
            
        }
        event.set("UCounter", x)
   end
    '
```

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [February 20, 2019, 3:04pm UTC](https://discuss.elastic.co/t/logstash-ruby-filter-condition-error/169005/2 "2019-02-20T15:04:35Z")

</div>

Is the value of the `offerList` really a string with the characters `NULL`?

Rather, are you testing for a missing `offerList` field? If so, then try `event.get("offerList").nil?`.  
`nil?` is a method available on all Ruby instances.

---

<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:** [March 20, 2019, 3:04pm UTC](https://discuss.elastic.co/t/logstash-ruby-filter-condition-error/169005/3 "2019-03-20T15:04:38Z")

</div>

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