# Ruby exception occurred

**URL:** <https://discuss.elastic.co/t/ruby-exception-occurred/105073>\
**Category:** Logstash\
**Created:** [October 24, 2017, 1:18pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred/105073 "2017-10-24T13:18:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [October 24, 2017, 1:18pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred/105073/1 "2017-10-24T13:18:13Z")

</div>

I am getting the error

`[2017-10-24T17:20:25,702][ERROR][logstash.filters.ruby] Ruby exception occurred: invalid byte sequence in UTF-8`

My ruby filter is:

```
       ruby {
              # isolate the server name from the "source" field
              # adding the field 'inputserver'
              code => "
                       event.set('inputserver', event.get('source').split('/')[4])
                       require 'csv'
                       CSV.foreach('/home/vpwrk1/LogStash/impls/logstash/cmerrortype.csv') do |rec|
                         if rec[0] == event.get('errorcodeiffailure')
                            event.set('exceptiontype', rec[1])
                         end
                       end
                      "
        }

```

Any idea?

Thanks  
Sharon.

---

<div class="post-metadata">

**Author:** ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)\
**Post date:** [October 26, 2017, 10:28am UTC](https://discuss.elastic.co/t/ruby-exception-occurred/105073/2 "2017-10-26T10:28:19Z")

</div>

Issue solved.

The csv input file had to be converted to UTF-8 before been used.

---

<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:** [November 23, 2017, 10:28am UTC](https://discuss.elastic.co/t/ruby-exception-occurred/105073/3 "2017-11-23T10:28:35Z")

</div>

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