UnicodeEncodeError in raygun4py

sandlerben

Posted on
Oct 05 2017

As you can see in the stacktrace below, Raygun failed to process an error because of a UnicodeEncodeError in raygunmsgs.py. As a result, I have no idea what the underlying error was (Raygun lost it).

I have two asks:

  • Can you all fix what seems to be a bug in your Python library?
  • Can you have your Python library log the error before trying to send it to your servers? (So that in case there is an issue on your end, developers can still debug)

Thank you!

Oct 04 09:24:59 clean-air-council app/web.1:  [2017-10-04 13:24:59 +0000] [11] [ERROR] Error handling request 
Oct 04 09:24:59 clean-air-council app/web.1:  Traceback (most recent call last): 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 130, in handle 
Oct 04 09:24:59 clean-air-council app/web.1:      self.handle_request(listener, req, client, addr) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 171, in handle_request 
Oct 04 09:24:59 clean-air-council app/web.1:      respiter = self.wsgi(environ, resp.start_response) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__ 
Oct 04 09:24:59 clean-air-council app/web.1:      return self.wsgi_app(environ, start_response) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/werkzeug/contrib/fixers.py", line 148, in __call__ 
Oct 04 09:24:59 clean-air-council app/web.1:      return self.app(environ, start_response) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app 
Oct 04 09:24:59 clean-air-council app/web.1:      response = self.make_response(self.handle_exception(e)) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/flask/app.py", line 1394, in handle_exception 
Oct 04 09:24:59 clean-air-council app/web.1:      got_request_exception.send(self, exception=e) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/blinker/base.py", line 267, in send 
Oct 04 09:24:59 clean-air-council app/web.1:      for receiver in self.receivers_for(sender)] 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/raygun4py/middleware/flask.py", line 27, in send_exception 
Oct 04 09:24:59 clean-air-council app/web.1:      self.sender.send_exception() 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/raygun4py/raygunprovider.py", line 76, in send_exception 
Oct 04 09:24:59 clean-air-council app/web.1:      errorMessage = raygunmsgs.RaygunErrorMessage(exc_type, exc_value, exc_traceback, options) 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/raygun4py/raygunmsgs.py", line 129, in __init__ 
Oct 04 09:24:59 clean-air-council app/web.1:      'localVariables': self._get_locals(frame[0]) if 'transmitLocalVariables' in options and options['transmitLocalVariables'] is True else None 
Oct 04 09:24:59 clean-air-council app/web.1:    File "/app/.heroku/python/lib/python2.7/site-packages/raygun4py/raygunmsgs.py", line 145, in _get_locals 
Oct 04 09:24:59 clean-air-council app/web.1:      result[key] = str(localVars[key]) 
Oct 04 09:24:59 clean-air-council app/web.1:  UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in position 438: ordinal not in range(128) 

Deleted User

Raygun

Posted on
Oct 30 2017

Hi there,

What version of raygun4py are you using?

From looking at the raygun4py source code (open source at https://github.com/MindscapeHQ/raygun4py) it seems to have error handling around these methods that should capture this issue. I'd recommend ensuring you have the latest version and also feel free to submit a PR for the provider if you know what is causing the issue in your case.

When it comes to logging out errors, we'd recommend using a standard logging package for this so you have more control over what gets logged locally and when. You can also configure the provider to use the same logger so errors can be logged out and sent to Raygun at the same time. https://github.com/MindscapeHQ/raygun4py#logging

Cheers.


Reply