Page 1 of 1

Internal Server Error - 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)

Published: November 19, 2020 - 11:45 AM
by Floflobel
Good morning,

On a newly installed client machine, I get an error when I try to access http://localhost:8088/.

Code: Select all

Internal Server Error
The server encountered an unexpected internal server error
(generated by waitress)
I noticed in the logs that there was an ASCII problem concerning the field: "host_info['system_manufacturer']":

Code: Select all

2020-11-19 10:27:03,398 [waitress       ] ERROR Exception while serving /
Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\lib\site-packages\waitress\channel.py", line 349, in service
    task.service()
  File "C:\Program Files (x86)\wapt\lib\site-packages\waitress\task.py", line 169, in service
    self.execute()
  File "C:\Program Files (x86)\wapt\lib\site-packages\waitress\task.py", line 439, in execute
    app_iter = self.channel.server.application(environ, start_response)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 117, in decorated
    return f(*args, **kwargs)
  File "C:\Program Files (x86)\wapt\waptservice\service.py", line 1443, in index
    return render_wapt_template('index.html',**data)
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 1307, in render_wapt_template
    return render_template(template_name_or_list, **context)
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\templating.py", line 140, in render_template
    ctx.app,
  File "C:\Program Files (x86)\wapt\lib\site-packages\flask\templating.py", line 120, in _render
    rv = template.render(context)
  File "C:\Program Files (x86)\wapt\lib\site-packages\jinja2\environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "C:\Program Files (x86)\wapt\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:\Program Files (x86)\wapt\waptservice\templates\index.html", line 1, in top-level template code
    {% extends "layout.html" %}
  File "C:\Program Files (x86)\wapt\waptservice\templates\layout.html", line 53, in top-level template code
    {% block content %}
  File "C:\Program Files (x86)\wapt\waptservice\templates\index.html", line 58, in block "content"
    <li>{{ _("System manufacturer : {0}").format(host_info['system_manufacturer']) }}</li>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)
Indeed, when I go to the console I see an ASCII problem in the "Model" and "Manufacturer" fields of my computer:
Screenshot_20201119_110716.png
Screenshot_20201119_110716.png (13.06 KB) Viewed 8553 times
(I have intentionally removed the job title and IP address)

I have approximately 28 workstations out of 2000 that have this problem.
  • WAPT Server version: 1.8.2
    WAPT Agent version: 1.8.2.7267
    WAPT Setup version: 1.8.2.7267
    WAPT Deploy version: 1.8.2.7267
Do you have any information about this problem and where it might be coming from?

Thanks in advance.

Re: Internal Server Error - 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)

Published: January 20, 2021 - 2:21 PM
by Floflobel
I'm just bumping this thread.

Re: Internal Server Error - 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)

Published: February 3, 2021 - 4:33 PM
by Floflobel
I'd like to bring this topic up again.

Re: Internal Server Error - 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)

Published: February 5, 2021 - 10:22 AM
by dcardon
As the message indicates, there are special characters in the manufacturer name (returned by dmidecode or wmi). You can patch the line in question by adding an ensure_unicode around the line host_info['system_manufacturer'].

Re: Internal Server Error - 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)

Published: February 8, 2021 - 5:55 PM
by Floflobel
Thank you for your feedback.

Do I need to patch and recompile the WAPT console? Or is there another way to do it?

Re: Internal Server Error - 'ascii' codec can't encode characters in position 0-32: ordinal not in range(128)

Published: February 11, 2021 - 1:44 PM
by dcardon
The next version of WAPT will be in Python 3 and should handle this scenario better. Otherwise, yes, a patch will be necessary.