Comment 1 for bug 1334482

Revision history for this message
Stuart Bishop (stub) wrote :

The traceback is showing a bug in the mongodb charm:

2014-06-19 20:23:17 INFO mongodb-relation-changed json_data = open(basepath + 'data/bikes/Valenbisi.JSON').read()

It is attempting to open a file in text mode without specifying the encoding, which will fail in some environments. You could force the system locale, which would mean this bug would only be triggered in locales not using UTF-8 encoding. Forcing a specific locale is not really appropriate, as if you are not using the system locale or you will end up with much harder to solve problems (things being sorted in the wrong order, unreadable filenames).

As the preferred encoding of JSON is UTF-8, the fix is to specify this in the open call (if you want read() to return unicode text), or open the file in binary mode if you want a UTF-8 encoded byte string.