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

UnicodeEncodeError when show slice record #1935

Closed
3 tasks done
raptium opened this issue Jan 10, 2017 · 7 comments
Closed
3 tasks done

UnicodeEncodeError when show slice record #1935

raptium opened this issue Jan 10, 2017 · 7 comments
Labels
!deprecated-label:bug Deprecated label - Use #bug instead inactive Inactive for >= 30 days

Comments

@raptium
Copy link

raptium commented Jan 10, 2017

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.
@xrmx
Copy link
Contributor

xrmx commented Jan 10, 2017

Since python3 work fine i'm tempted to start adding from __future__ import unicode_literals on top of each file so that we'll handle strings the same way.

@mistercrunch
Copy link
Member

Using mysql? Tried setting the charset on the connection string as in mysql://user:[email protected]/db?charset=utf8?

@yamyamyuo
Copy link
Contributor

Using mysql? Tried setting the charset on the connection string as in mysql://user:[email protected]/db?charset=utf8? @mistercrunch

this can fix dashboard show record, however, slice show record is still 500 error

@yamyamyuo
Copy link
Contributor

I have solved this problem. I am using py2.

  1. you should fix mysql url by mysql://user:[email protected]/db?charset=utf8
  2. if you are using py2, you should specify
if sys.version_info.major < 3:
    reload(sys)
sys.setdefaultencoding('utf8')

and then things works ☄️

@xrmx
Copy link
Contributor

xrmx commented Mar 27, 2018

@yamyamyuo that's not a fix, which version are you using?

@yamyamyuo
Copy link
Contributor

@xrmx I am using superset 0.22.1
If I use chinese characters in dashboard name or slice name , the above issues will show.
I noticed that mysql db data has question mark (?) instead of chinese characters. So I set the mysql charset. This problem is solved after setdefaultencoding.

@stale
Copy link

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.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 11, 2019
@stale stale bot closed this as completed Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

4 participants