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.

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 4

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.4

Expected results

change the metadata db from db2 to previous db1 can work

Actual results

after changing to db1, exists the encoding error

Steps to reproduce

  1. add ?charset=utf8 in sqlalchemy_database_uri , and create database db1 character set utf8, use db1 as the metadata db, works
  2. add ?charset=utf8 in sqlalchemy_database_uri , and create database db2 character set utf8, use db2 as the metadata db, works
  3. change the sqlalchemy_database_uri from db2 to db1
  4. view a slice or use SQL Lab, occur the encoding bug

python3.5 superset 0.15.4 mysql 5.7

File "/home/jiajie/project/superset/superset/superset/views.py", line 1588, in explore
    datasources = sorted(datasources, key=lambda ds: ds.full_name)
  File "/home/jiajie/project/superset/superset/superset/views.py", line 1588, in <lambda>
    datasources = sorted(datasources, key=lambda ds: ds.full_name)
  File "/home/jiajie/project/superset/superset/superset/models.py", line 1155, in full_name
    self.database, self.table_name, schema=self.schema)
......................
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.1.5.dev0-py3.5-linux-x86_64.egg/sqlalchemy/orm/strategies.py", line 557, in _load_for_state
    return self._emit_lazyload(session, state, ident_key, passive)
  File "\<string\>", line 1, in \<lambda\>
    
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.1.5.dev0-py3.5-linux-x86_64.egg/sqlalchemy/orm/strategies.py", line 603, in _emit_lazyload
    return loading.load_on_ident(q, ident_key)
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.1.5.dev0-py3.5-linux-x86_64.egg/sqlalchemy/orm/loading.py", line 223, in load_on_ident
    return q.one()
  .......
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.1.5.dev0-py3.5-linux-x86_64.egg/sqlalchemy/util/compat.py", line 186, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.1.5.dev0-py3.5-linux-x86_64.egg/sqlalchemy/orm/loading.py", line 75, in instances
    rows = [proc(row) for row in fetch]
  File "/usr/local/lib/python3.5/dist-packages/SQLAlchemy-1.1.5.dev0-py3.5-linux-x86_64.egg/sqlalchemy/orm/loading.py", line 75, in <listcomp>
    rows = [proc(row) for row in fetch]
 ....................
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy_utils/types/encrypted.py", line 261, in process_result_value
    decrypted_value = self.engine.decrypt(value)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy_utils/types/encrypted.py", line 89, in decrypt
    decrypted = decrypted.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe5 in position 4: invalid continuation byte

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
kkalyancommented, Apr 13, 2017

this is a workaround you can use - convert the utf field to ascii using mysql expression in the edit dimension.

image

or include ?charset=utf8 in the SQLAlchemy URL

1reaction
jhultcommented, Sep 17, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

'utf-8' codec can't decode byte - Stack Overflow
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position 183: invalid continuation byte. So this is how I fixed it.
Read more >
UnicodeDecodeError: 'utf8' codec can't decode ... - ItsMyCode
What is UnicodeDecodeError 'utf8' codec can't decode byte? The UnicodeDecodeError normally happens when decoding a string from a certain coding.
Read more >
Python3 Fix→ UnicodeDecodeError: 'utf-8' codec can't decode ...
UnicodeDecodeError : 'utf-8' codec can't decode byte 0x84 in position ... With Encoding (Save As in Notepad); Select UTF-8 for your encoding.
Read more >
'utf8' codec can't decode byte 0xa5 in position 0: invalid start ...
Often, while reading the input files, you might encounter an UnicodeDecodeError. · Thus, the error means that the byte 0xa05 at position 0...
Read more >
How to resolve a UnicodeDecodeError for a CSV file - Kaggle
_string_box_utf8() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcc in position 1: invalid continuation byte During handling of the above exception, ...
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