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

Permalinks doesn't work: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte #28565

Open
3 tasks done
sensorsasha opened this issue May 17, 2024 · 1 comment
Labels
dashboard Namespace | Anything related to the Dashboard

Comments

@sensorsasha
Copy link

sensorsasha commented May 17, 2024

Bug description

We're running superset using docker-compose-non-dev.yml. All users are admins. When a user tries to create a permalink to a dashboard it doesn't work.

How to reproduce the bug

  1. Create a dashboard.
  2. Click on "Copy permalink to clipboard".
  3. You get "sorry, something went wrong" error.

Request from the dev tools
POST myhostname.com/api/v1/dashboard/63/permalink

Body:

{"urlParams":[],"dataMask":{"437":{"id":"437","extraFormData":{},"filterState":{},"ownState":{}},"NATIVE_FILTER-JD6CVYqbS":{"id":"NATIVE_FILTER-JD6CVYqbS","extraFormData":{"time_range":"DATEADD(DATETIME(\"2024-05-16T00:00:00\"), -7, day) : 2024-05-16T00:00:00"},"filterState":{"value":"DATEADD(DATETIME(\"2024-05-16T00:00:00\"), -7, day) : 2024-05-16T00:00:00"},"ownState":{}},"NATIVE_FILTER-c-dcmnbdQ":{"id":"NATIVE_FILTER-c-dcmnbdQ","extraFormData":{},"filterState":{},"ownState":{}},"NATIVE_FILTER-B8llqgi_O":{"id":"NATIVE_FILTER-B8llqgi_O","extraFormData":{},"filterState":{},"ownState":{}}},"activeTabs":[]}

Error in the superset_app container logs

2024-05-16 16:22:10,540:ERROR:flask_appbuilder.api:'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/flask_appbuilder/api/__init__.py", line 110, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/utils/log.py", line 255, in wrapper
    value = f(*args, **kwargs)
  File "/app/superset/views/base_api.py", line 93, in wraps
    return f(self, *args, **kwargs)
  File "/app/superset/dashboards/permalink/api.py", line 97, in post
    key = CreateDashboardPermalinkCommand(
  File "/app/superset/commands/dashboard/permalink/create.py", line 60, in run
    key=get_deterministic_uuid(self.salt, (user_id, value)),
  File "/app/superset/commands/dashboard/permalink/base.py", line 35, in salt
    return get_permalink_salt(SharedKey.DASHBOARD_PERMALINK_SALT)
  File "/app/superset/key_value/shared_entries.py", line 51, in get_permalink_salt
    salt = get_shared_value(key)
  File "/app/superset/key_value/shared_entries.py", line 34, in get_shared_value
    return GetKeyValueCommand(RESOURCE, key=uuid_key, codec=CODEC).run()
  File "/app/superset/commands/key_value/get.py", line 60, in run
    return self.get()
  File "/app/superset/commands/key_value/get.py", line 71, in get
    return self.codec.decode(entry.value)
  File "/app/superset/key_value/types.py", line 78, in decode
    return json.loads(value)
  File "/usr/local/lib/python3.9/json/__init__.py", line 341, in loads
    s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
77.54.193.217 - - [16/May/2024:16:22:10 +0000] "POST /api/v1/dashboard/60/permalink HTTP/1.1" 500 26 "https://myhostname.com/superset/dashboard/consumer-intel-cohorts-modules-enabled/?native_filters_key=h4REjeqI3GSg8oqqmM5ULv-u6A7s9J6nfcP86wALNu1ZiXu5UgpFOxpv7pJ19heI" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"

Screenshots/recordings

Screenshot 2024-05-17 at 15 27 17
Screenshot 2024-05-17 at 15 27 25

Superset version

3.1.3

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
@dosubot dosubot bot added the dashboard Namespace | Anything related to the Dashboard label May 17, 2024
Copy link

dosubot bot commented May 17, 2024

The error you're encountering, 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte, typically indicates an issue with handling binary data not encoded in UTF-8. This problem often arises in Superset when dealing with permalinks, as the system uses various codecs for encoding and decoding data, and it seems like the binary data is not being correctly handled or converted.

To address this issue, you might need to review and adjust the encoding/decoding logic for permalinks in Superset. This involves ensuring that any binary data, possibly generated by pickle serialization, is properly managed. Given the nature of the error, it's likely related to the handling of serialized data that isn't UTF-8 encoded.

A similar issue has been reported and discussed within the Superset community. A workaround that was suggested involved running a script to convert key-value entries to JSON, specifically targeting app and dashboard_permalink resources. This script is intended to be executed in the superset shell. However, this approach requires caution, as it involves direct manipulation of the database. It's crucial to back up your database before attempting any such operations.

If this workaround does not resolve the issue, or if you're hesitant to directly modify the database, it might be beneficial to provide more detailed logs or traceback information. This additional context can help in diagnosing the problem more accurately and finding a more precise solution.

Details

Sources


About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboard Namespace | Anything related to the Dashboard
Projects
None yet
Development

No branches or pull requests

1 participant