'ascii' codec can't decode in 3.2.2


After upgrading Indico from 2.3 to 3.2.2 without any problem, Indico sent an error message with the subject: Unexpected Exception occurred at indico1.kfki.hu: ‘ascii’ codec can’t decode byte 0xc2 in position 14853: ordinal not in range(128)
How could we fix the issue?

Thanks in advance,

You need to provide full traceback… if it was an error email, the email’s body contains the interesting parts.

Here follows the full email, sorry for the broken long lines. I don’t see a way to attach file:

2023-02-06 23:37:40,604  b8b4e8e8a65b49c0  indico.flask - ERROR errors.py:110 -- 'ascii'
codec can't decode byte 0xc2 in position 14853: ordinal not in range(128)

Traceback (most recent call last):
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/app.py", line 1820, in
    rv = self.dispatch_request()
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/app.py", line 1796, in
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/blueprint.py",
line 85, in i18n_locale_react
    return _get_i18n_locale(locale_name, react=True)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/blueprint.py",
line 107, in _get_i18n_locale
    i18n_data = generate_i18n_file(locale_name, react=react)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/vars_js.py",
line 47, in generate_i18n_file
    i18n_data = get_locale_data(root_path, locale_name, 'indico', react=react)
  File "/services/indico/.venv/lib/python3.9/site-packages/indico/web/assets/vars_js.py",
line 29, in get_locale_data
    rv = json.load(f)
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/json/__init__.py", line
251, in load
    return app.json.load(fp, **kwargs)
  File "/services/indico/.venv/lib/python3.9/site-packages/flask/json/provider.py", line
74, in load
    return self.loads(fp.read(), **kwargs)
  File "/services/indico/.pyenv/versions/3.9.16/lib/python3.9/encodings/ascii.py", line 26,
in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 14853: ordinal not in

{'data': {'get': {},
          'headers': {'Accept': '*/*',
                      'Accept-Encoding': 'gzip, deflate',
                      'Accept-Language': 'en-US,en;q=0.9',
                      'Connection': 'keep-alive',
                      'Host': 'indico.wigner.hu',
                      'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X '
                                    '10_15_5) AppleWebKit/605.1.15 (KHTML, '
                                    'like Gecko) Version/13.1.1 '
                                    'Safari/605.1.15 (Applebot/0.1; '
          'json': None,
          'post': {},
          'url': {'locale_name': 'en_GB'}},
'endpoint': 'assets.i18n_locale_react',
 'id': 'b8b4e8e8a65b49c0',
 'ip': '',
 'method': 'GET',
 'referrer': 'https://indico.wigner.hu/event/4/timetable/?view=standard',
 'rh': None,
 'time': '2023-02-06T23:37:40.673171',
 'url': 'https://indico.wigner.hu/assets/i18n/en_GB-react.js',
 'user': None,
 'user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) '
               'AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 '
               'Safari/605.1.15 (Applebot/0.1; '

For some reason your Python uses the ascii codec by default instead of utf-8 which is supposed to be the standard in Python 3.

Fixing this will also make the error go away. Is your LC_TYPE not set to an UTF8 locale by any chance?

Tip: For testing simply go to https://indico.wigner.hu/assets/i18n/en_GB-react.js directly and see if it works or not.

PS: I added backtick fences around your pasted content, that way it’s properly rendered in monospace (Discourse uses Markdown for formatting).

DEFAULT_LOCALE was left to the default en_GB in indico.conf. Now I set it to en_US.UTF-8 and restarted uwsgi. Going to the https://indico.wigner.hu/assets/i18n/en_GB-react.js URL it seems it loads OK and no error email sent.

Thanks indeed! You are doing a great support!

The indico.conf locale should NOT matter there and in fact en_US.UTF-8 there is not a valid locale as far as Indico is concerned I’m very surprised that this fixed something - unless it was just the uwsgi restart that fixed whatever problem you had before…

In any case, it’d be better to change the system locale (global LC_CTYPE value).

Also, could you paste the current output when running locale on a terminal to see what’s currently configured?

The system locale was set to “C”. I modified it to en_US.UTF-8, configured DEFAULT_LOCALE back to en_GB in indico.conf and restarted uwsgi.

All seems to be good :slight_smile: