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

sqllab - Invalid decryption key #24620

Closed
hughpearse opened this issue Jul 7, 2023 · 9 comments
Closed

sqllab - Invalid decryption key #24620

hughpearse opened this issue Jul 7, 2023 · 9 comments

Comments

@hughpearse
Copy link

A clear and concise description of what the bug is.

How to reproduce the bug

  1. git clone https://github.com/apache/superset.git
  2. cd superset
  3. git checkout 3.0.0rc1
  4. vim ./docker/pythonpath_dev/superset_config.py
    :107
    WTF_CSRF_ENABLED = False
    SESSION_COOKIE_SAMESITE = None
    SESSION_COOKIE_SECURE = False
    SESSION_COOKIE_HTTPONLY = False
    SECRET_KEY = "0KI7YkJ2I04Hdy+Cdt2Dm9BzBxP7M/eiBBjT6ax4ZWmBxk39m3XSq3IZ"
  5. TAG=3.0.0rc1 docker-compose -f docker-compose.yml build --no-cache
  6. TAG=3.0.0rc1 docker-compose -f docker-compose.yml up
  7. http://hostname:8088/
    username: admin / password: admin
  8. Navigate to Sql Lab -> Query

Expected results

The query dashboard opens

Actual results

GET http://hostname:8088/superset/sqllab/
500 INTERNAL SERVER ERROR

Body

{"errors": [{"message": "Invalid decryption key", "error_type": "GENERIC_BACKEND_ERROR", "level": "error", "extra": {"issue_codes": [{"code": 1011, "message": "Issue 1011 - Superset encountered an unexpected error."}]}}]}

Screenshots

If applicable, add screenshots to help explain your problem.

Environment

vanilla docker-compose deployment

Checklist

Make sure to follow these steps before submitting your issue - thank you!

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

Additional context

superset_app             | 2023-07-07 15:36:07,201:ERROR:superset.views.base:Invalid decryption key
superset_app             | Traceback (most recent call last):
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 126, in decrypt
superset_app             |     decrypted = decrypted.decode('utf-8')
superset_app             | UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 2: invalid start byte
superset_app             |
superset_app             | During handling of the above exception, another exception occurred:
superset_app             |
superset_app             | Traceback (most recent call last):
superset_app             |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1823, in full_dispatch_request
superset_app             |     rv = self.dispatch_request()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1799, in dispatch_request
superset_app             |     return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
superset_app             |   File "/usr/local/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py", line 139, in wraps
superset_app             |     return f(self, *args, **kwargs)
superset_app             |   File "/app/superset/utils/log.py", line 255, in wrapper
superset_app             |     value = f(*args, **kwargs)
superset_app             |   File "/app/superset/views/core.py", line 1097, in sqllab
superset_app             |     **self._get_sqllab_tabs(get_user_id()),
superset_app             |   File "/app/superset/views/core.py", line 1056, in _get_sqllab_tabs
superset_app             |     for database in DatabaseDAO.find_all():
superset_app             |   File "/app/superset/daos/base.py", line 114, in find_all
superset_app             |     return query.all()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/query.py", line 2768, in all
superset_app             |     return self._iter().all()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 1371, in all
superset_app             |     return self._allrows()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 401, in _allrows
superset_app             |     rows = self._fetchall_impl()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 1284, in _fetchall_impl
superset_app             |     return self._real_result._fetchall_impl()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 1696, in _fetchall_impl
superset_app             |     return list(self.iterator)
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/loading.py", line 147, in chunks
superset_app             |     fetch = cursor._raw_all_rows()
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 393, in _raw_all_rows
superset_app             |     return [make_row(row) for row in rows]
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/result.py", line 393, in <listcomp>
superset_app             |     return [make_row(row) for row in rows]
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/type_api.py", line 1681, in process
superset_app             |     return process_value(impl_processor(value), dialect)
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 479, in process_result_value
superset_app             |     value = super().process_result_value(value=value, dialect=dialect)
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 424, in process_result_value
superset_app             |     decrypted_value = self.engine.decrypt(value)
superset_app             |   File "/usr/local/lib/python3.9/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 128, in decrypt
superset_app             |     raise ValueError('Invalid decryption key')
superset_app             | ValueError: Invalid decryption key
superset_app             | 2023-07-07 15:36:07,205:INFO:werkzeug:172.30.91.146 - - [07/Jul/2023 15:36:07] "GET /superset/sqllab/ HTTP/1.1" 500 -
@eschutho
Copy link
Member

eschutho commented Jul 7, 2023

@hughpearse Does this closed issue solve your error? #8538

@Teesmo
Copy link

Teesmo commented Feb 5, 2024

hi @eschutho. Is there a way to fix this if I have lost my previous secret key?

@NascentKiosk
Copy link

I used "pip install apache-superset --upgrade" instead of "pip install apache-superset" and this solved the issue

@hirensoni913
Copy link

hi @eschutho. Is there a way to fix this if I have lost my previous secret key?

Hi @Teesmo, @eschutho did you find the answer to your question? I got in the same situation. I have lost the previous secrete_key. If yes, could you please guide me?

@NascentKiosk
Copy link

NascentKiosk commented Mar 1, 2024

What I did was to delete the database file in .superset folder. This allowed me to do a new installation and thus solved the issue

@hirensoni913
Copy link

@NascentKiosk I just resolved the issue by creating a new connection and updating all the database_id in every referenced table with the newly created database_id. Then deleted the existing connection and everything is back to normal.

@rusackas
Copy link
Member

rusackas commented Mar 4, 2024

Sounds like this one is more or less mitigated. Please let us know if this needs any revisiting.

@rusackas rusackas closed this as completed Mar 4, 2024
@hirensoni913
Copy link

@rusackas You are right. But there is still an issue perhaps on a document level. At one point it reads that if you have lost the previous key, try to re-encrypt with a new key and everything should be back on track. But when you do it, it says the old key must be provided. So the steps are right but only when you want to change your secret_key and not when you have lost it.

@rusackas
Copy link
Member

rusackas commented Mar 4, 2024

@hirensoni913 Gotcha. Would you be willing to either open a Docs PR (there's a new button in the bottom right of the docs pages to do so) or enumerate here what the steps for a lost key should be if the key was lost? CC @dpgaspar @sfirke who might know this process and be able to help with the docs effort as well.

@dosubot dosubot bot mentioned this issue Sep 7, 2024
3 tasks
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

6 participants