You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/09/17 20:25:56 UTC

[GitHub] [superset] jhult commented on issue #8538: Change SECRET_KEY and get error `ValueError: Invalid decryption key` on K8s

jhult commented on issue #8538:
URL: https://github.com/apache/superset/issues/8538#issuecomment-922061313


   The databases page would not load for me after changing the `SECRET_KEY`. Here is how I fixed it:
   
   ```
   psql -d superset -U superset -W
   # Password for user superset:
   select database_name, password from dbs;
   update dbs set password = null;
   ```
   
   Now the databases page will load but clicking edit on certain databases still didn't work and caused this stack trace:
   
   ```
   Unable to load dialect <class 'sqlalchemy.dialects.mssql.adodbapi.MSDialect_adodbapi'>: type object 'MSDialect_adodbapi' has no attribute 'dbapi'
   2021-09-17 18:29:43,812:WARNING:superset.db_engine_specs:Unable to load dialect <class 'sqlalchemy.dialects.mssql.adodbapi.MSDialect_adodbapi'>: type object 'MSDialect_adodbapi' has no attribute 'dbapi'
   2021-09-17 18:29:43,819:ERROR:root:Invalid decryption key
   Traceback (most recent call last):
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 126, in decrypt
       decrypted = decrypted.decode('utf-8')
   UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 2: invalid start byte
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/api/__init__.py", line 85, in wraps
       return f(self, *args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/api/__init__.py", line 155, in wraps
       return f(self, *args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/api/__init__.py", line 1448, in get
       return self.get_headless(pk, **kwargs)
     File "/app/superset/utils/log.py", line 242, in wrapper
       value = f(*args, **kwargs)
     File "/app/superset/views/base_api.py", line 390, in get_headless
       duration, response = time_function(super().get_headless, pk, **kwargs)
     File "/app/superset/utils/core.py", line 1461, in time_function
       response = func(*args, **kwargs)
     File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/api/__init__.py", line 1344, in get_headless
       item = self.datamodel.get(pk, self._base_filters, self.show_select_columns)
     File "/usr/local/lib/python3.7/site-packages/flask_appbuilder/models/sqla/interface.py", line 935, in get
       query, _filters, select_columns=select_columns
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3459, in one_or_none
       ret = list(self)
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 100, in instances
       cursor.close()
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 70, in __exit__
       with_traceback=exc_tb,
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
       raise exception
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 80, in instances
       rows = [proc(row) for row in fetch]
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 80, in <listcomp>
       rows = [proc(row) for row in fetch]
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 588, in _instance
       populators,
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 725, in _populate_full
       dict_[key] = getter(row)
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/type_api.py", line 1278, in process
       return process_value(impl_processor(value), dialect)
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 469, in process_result_value
       value = super().process_result_value(value=value, dialect=dialect)
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 414, in process_result_value
       decrypted_value = self.engine.decrypt(value)
     File "/usr/local/lib/python3.7/site-packages/sqlalchemy_utils/types/encrypted/encrypted_type.py", line 128, in decrypt
       raise ValueError('Invalid decryption key')
   ValueError: Invalid decryption key
   ```
   
   Create a new database (e.g. name = "New DB") from the UI. You can get the SQLAlchemy URI using this SQL:
   
   ```
   select sqlalchemy_uri from dbs where database_name = 'Original DB';
   ```
   
   Once the new database is created, back in `psql`:
   
   ```
   select database_name, id from dbs where database_name = 'New DB' or database_name = 'Original DB';
   # 5 = New DB
   # 2 = Original DB
   update tables set database_id = 5 where database_id = 2;
   update tab_state set database_id = 5 where database_id = 2;
   update query set database_id = 5 where database_id = 2;
   update saved_query set db_id = 5 where db_id = 2;
   update table_schema set database_id = 5 where database_id = 2;
   delete from dbs where database_name = 'Original DB';
   update dbs set database_name = 'Original DB' where database_name = 'New DB';
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org