Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xe4 in position 2 #681

Open
zaghost opened this issue Feb 19, 2019 · 1 comment

Comments

@zaghost
Copy link

zaghost commented Feb 19, 2019

I got '500 Internal Server Error' when I clicked 'New Instance' button in a host,
I checked /var/log/supervisor/webvirtmgr.log and found there was an exception:

ERROR:django.request:Internal Server Error: /create/1/
Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 115, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/var/www/webvirtmgr/create/views.py", line 144, in create
return render_to_response('create.html', locals(), context_instance=RequestContext(request))
File "/usr/lib/python2.6/site-packages/django/shortcuts/init.py", line 29, in render_to_response
return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/python2.6/site-packages/django/template/loader.py", line 177, in render_to_string
return t.render(context_instance)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 140, in render
return self._render(context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/loader_tags.py", line 124, in render
return compiled_parent._render(context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 134, in _render
return self.nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/loader_tags.py", line 63, in render
result = block.nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py", line 285, in render
return nodelist.render(context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 830, in render
bit = self.render_node(node, context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node
return node.render(context)
File "/usr/lib/python2.6/site-packages/django/template/defaulttags.py", line 196, in render
nodelist.append(node.render(context))
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 887, in render
return _render_value_in_context(output, context)
File "/usr/lib/python2.6/site-packages/django/template/base.py", line 865, in _render_value_in_context
value = force_text(value)
File "/usr/lib/python2.6/site-packages/django/utils/encoding.py", line 115, in force_text
raise DjangoUnicodeDecodeError(s, *e.args)
DjangoUnicodeDecodeError: 'utf8' codec can't decode byte 0xe4 in position 2: unexpected end of data. You passed in 'ea\xe4\xc8' (<type 'str'>)

@zaghost
Copy link
Author

zaghost commented Mar 22, 2019

After debug, I found if there are file with messy code filename in user's home directory in host machine, then the page [host] -> [New Instance] will show a Error page
In django/template/base.py, it try to decode string of filenames as utf-8
[host] -> [New Instance] -> [Custom Instance] -> [HDD] list all files in home directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant