"\xC3" from ASCII-8BIT to UTF-8 Error when track exception

Zhisong

Posted on
Oct 13 2020

Environment:

  • ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
  • raygun4ruby 3.2.1

We call the raygun api to track exceptions and sometimes there will be some special characters in the http request like á. With this kind of characters in the request, we will get the "\xC3" from ASCII-8BIT to UTF-8 Error when track exception error and this will bury our real error. Please help with this, how can we avoid it or can raygun team fix it?

The related part of the backtrace:

Message: "\xC3" from ASCII-8BIT to UTF-8

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/json-1.8.6/lib/json/common.rb:223 encode

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/json-1.8.6/lib/json/common.rb:223 generate

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/json-1.8.6/lib/json/common.rb:223 generate

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun/client.rb:252 create_entry

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun/client.rb:28 track_exception

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun.rb:131 trackexceptionsync

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun.rb:65 track_exception

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun.rb:152 rescue in trackexceptionsync

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun.rb:128 trackexceptionsync

/home/deploy/apps/vydia/shared/bundle/ruby/2.5.0/gems/raygun4ruby-3.2.1/lib/raygun.rb:65 track_exception


Mitchell

Raygun

Posted on
Oct 15 2020

Hi Zhisong,

After doing some investigation we found a possible solution to your issue. We would recommend forcing the encoding of any custom data to use UTF-8. Please trying updating each use of custom data with .force_encoding("UTF-8"). For example when manually recording an error:

customValue = "dátá"
Raygun.trackexception(e, customdata: {my: customValue.force_encoding("UTF-8"), goes: 'here'})

Please try this solution and let us know if the problem persists.

I will make a note of this issue for us to address in a future release of the Raygun4Ruby provider.

Thank you,
Mitchell.


Zhisong

Posted on
Oct 26 2020

Hello Mitchell,

Thanks for the response. I'll try your suggestions and keep you posted.


Reply