Logstash Rspec Encoding as US-ASCII

Hi,

I am running an Rspec test case which takes in some json files and matches them against an expected output after being put through my filter.

However, I am getting an error during the validate_valie phase where it is complaining that US-ASCII is being used, instead of UTF-8, even though US-ASCII is a subset of UTF-8.

Any suggestions as to how I can force the encoding?

Thanks

Below is the stack trace I am getting

 RuntimeError:
       expected UTF-8 encoding for value=Paid Aggregator, encoding=#<Encoding:US-ASCII>
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-event-2.4.1-java/lib/logstash/event.rb:226:in `validate_value'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-event-2.4.1-java/lib/logstash/event.rb:230:in `validate_value'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-event-2.4.1-java/lib/logstash/event.rb:230:in `validate_value'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-devutils-0.0.22-java/lib/logstash/devutils/rspec/spec_helper.rb:43:in `[]='
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-2.4.1-java/lib/logstash/util/decorators.rb:46:in `add_tags'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-2.4.1-java/lib/logstash/util/decorators.rb:38:in `add_tags'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-2.4.1-java/lib/logstash/filters/base.rb:180:in `filter_matched'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-filter-grok-2.0.5/lib/logstash/filters/grok.rb:287:in `filter'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-2.4.1-java/lib/logstash/filters/base.rb:151:in `multi_filter'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-2.4.1-java/lib/logstash/filters/base.rb:148:in `multi_filter'
     # (eval):3950:in `initialize'
     # (eval):3943:in `initialize'
     # (eval):3964:in `initialize'
     # (eval):3961:in `initialize'
     # (eval):4008:in `initialize'
     # (eval):3989:in `initialize'
     # (eval):1176:in `filter_func'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-core-2.4.1-java/lib/logstash/pipeline.rb:425:in `filter'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-devutils-0.0.22-java/lib/logstash/devutils/rspec/logstash_helpers.rb:49:in `results'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/logstash-devutils-0.0.22-java/lib/logstash/devutils/rspec/logstash_helpers.rb:47:in `results'
     # ./spec/spec_helper.rb:50:in `run_case'
     # /usr/local/rvm/gems/jruby-1.7.26/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `(root)'

Got this. The solution is to use the "magic_encoding" gem

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