question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeEncodeError when show slice record

See original GitHub issue

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven’t found one similar

Superset version

0.15.1

Expected results

The Slice Page

Actual results

500 Server Error Page with Stacktrace

        Traceback (most recent call last):
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/security/decorators.py", line 26, in wraps
    return f(self, *args, **kwargs)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/views.py", line 469, in show
    related_views=self._related_views)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/baseviews.py", line 158, in render_template
    return render_template(template, **dict(list(kwargs.items()) + list(self.extra_args.items())))
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/templating.py", line 134, in render_template
    context, ctx.app)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask/templating.py", line 116, in _render
    rv = template.render(context)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/templates/appbuilder/general/model/show.html", line 2, in top-level template code
    {% import 'appbuilder/general/lib.html' as lib %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/templates/appbuilder/base.html", line 1, in top-level template code
    {% extends base_template %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/superset/templates/superset/base.html", line 1, in top-level template code
    {% extends "appbuilder/baselayout.html" %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/superset/templates/appbuilder/baselayout.html", line 2, in top-level template code
    {% import 'appbuilder/baselib.html' as baselib %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/templates/appbuilder/init.html", line 46, in top-level template code
    {% block body %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/superset/templates/appbuilder/baselayout.html", line 21, in block "body"
    {% block content %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/templates/appbuilder/general/model/show.html", line 25, in block "content"
    {% block show_form %}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/templates/appbuilder/general/model/show.html", line 27, in block "show_form"
    {{ widgets.get('show')()|safe }}
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/widgets.py", line 34, in __call__
    return template.render(args)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/users/guanhao/apps/superset/venv/lib/python2.7/site-packages/flask_appbuilder/templates/appbuilder/general/widgets/show.html", line 33, in top-level template code
    <td><span style="white-space: pre-line">{{value_columns[loop.index-1]}}</span></td>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

Steps to reproduce

  1. Create a dashboard with name in non-ascii characters, eg. 测试.
  2. Create a slice and add it to the dashboard created above.
  3. Click Show Record link on the slice list.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mistercrunchcommented, Sep 27, 2017

Using mysql? Tried setting the charset on the connection string as in mysql://user:password@1.1.1.1/db?charset=utf8?

0reactions
stale[bot]commented, Apr 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeEncodeError when show slice record · Issue #1935
Create a dashboard with name in non-ascii characters, eg. 测试 . Create a slice and add it to the dashboard created above. Click...
Read more >
UnicodeEncodeError: 'ascii' codec can't encode character ...
The issue is that when you call str(), python uses the default character encoding to try and encode the bytes you gave it,...
Read more >
4. Unicode Text Versus Bytes - Fluent Python, 2nd Edition ...
Implicit conversion of byte sequences to Unicode text is a thing of the past. This chapter deals with Unicode strings, binary sequences, and...
Read more >
Unicode: Adding Thousands of Characters to Your Mac
Today we'll show you how that's done using Unicode and the Option key. ... On your standard Mac keyboard, just type Option and...
Read more >
csv package - encoding/csv
A record is a slice of strings with each string being one field. Writes are buffered, so Flush must eventually be called to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found