jembi / openhim-webui

This project is a web user interface for the OpenHIM project (https://github.com/jembi/openhim). It provides views and management of the transaction log, as well as monitoring statistics.
Mozilla Public License 2.0
0 stars 1 forks source link

Unicode decoding error #2

Closed rcrichton closed 10 years ago

rcrichton commented 11 years ago

It seems that there are some characters in the request message that cannot be decoded as unicode for some reason. This is the error message:

500 Internal Server Error

The server encountered an unexpected condition which prevented it from fulfilling the request.

Traceback (most recent call last): File "/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py", line 656, in respond response.body = self.handler() File "/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py", line 188, in call self.body = self.oldhandler(_args, _kwargs) File "/usr/lib/python2.7/dist-packages/cherrypy/_cpdispatch.py", line 34, in call return self.callable(_self.args, _self.kwargs) File "openhim-webui/errorui.py", line 184, in index return tmpl.render(row=row, username=getUsername(), max=max) File "/usr/lib/python2.7/dist-packages/mako/template.py", line 302, in render return runtime.render(self, self.callable, args, data) File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 660, in _render *_kwargs_forcallable(callable, data)) File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 692, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/usr/lib/python2.7/dist-packages/mako/runtime.py", line 718, in _exectemplate callable(context, _args, _kwargs) File "/tmp/mako_modules/transview.html.py", line 118, in render_body __M_writer(filters.xml_escape(unicode(row[4] ))) UnicodeDecodeError: 'utf8' codec can't decode byte 0x9d in position 3737: invalid start byte

rcrichton commented 10 years ago

Example of such a transaction: /transview/?id=68591

Email to Desire, about this:

Hi Desire,

For this problem it seems that the http body of the message that is received for these failing message contains content that is not UTF-8 encoded. This seems to be the root of the problem. Would you be able to look into this further and see if you can figure out what is being sent that is causing this? I will keep looking into it as well, but I have other priorities so I can't spend too much time on this.

I'd suggest looking through the content of the body that is stored in the HIM database to see if we can find anything peculiar about the text stored there.

Cheers, Ryan

rcrichton commented 10 years ago

@ruzdezzy If you find any more about this issue please comment on this thread.

ruzdezzy commented 10 years ago

@rcrichton currently looking at what might be causing the problem will comment as soon as I get something

hnnesv commented 10 years ago

I wonder if this error isn't caused by the mysql connector not returning data in unicode?

I wouldn't be surprised if the connector were using the default system encoding, which in python, inconveniently enough, isn't unicode (it's ascii usually). It looks from the error that mako is however explicitly trying to use unicode.

The mysql connector does have the option use_unicode when creating a connection: http://mysql-python.sourceforge.net/MySQLdb.html#functions-and-attributes Might be worth a shot?

ruzdezzy commented 10 years ago

Thanks @devcritter will investigate