airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Backes (JIRA)" <>
Subject [jira] [Created] (AIRFLOW-1970) Database cannot be initialized if an invalid fernet key is provided
Date Fri, 05 Jan 2018 17:53:00 GMT
Michael Backes created AIRFLOW-1970:

             Summary: Database cannot be initialized if an invalid fernet key is provided
                 Key: AIRFLOW-1970
             Project: Apache Airflow
          Issue Type: Bug
          Components: configuration
    Affects Versions: 1.9.0
         Environment: Python 2.7.12
PostgreSQL 9.6.3
            Reporter: Michael Backes

If I use an invalid fernet key in my config file, I'm not able to run "airflow initdb" successfully.

For example if I have the following in my config:

# Secret key to save connection passwords in the db
fernet_key = xxx

I will get the following error when running "airflow initdb":

[2018-01-05 16:43:00,525] {} INFO - Using executor LocalExecutor
DB: postgresql+psycopg2://airflow_user:secret_pw@some.address:5432/airflow
[2018-01-05 16:43:00,624] {} INFO - Creating tables
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
Traceback (most recent call last):
  File "/usr/local/bin/airflow", line 27, in <module>
  File "/usr/local/lib/python2.7/site-packages/airflow/bin/", line 897, in initdb
  File "/usr/local/lib/python2.7/site-packages/airflow/utils/", line 114, in initdb
  File "<string>", line 4, in __init__
  File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/", line 414, in _initialize_instance
    manager.dispatch.init_failure(self, args, kwargs)
  File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/util/", line 66,
in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib64/python2.7/site-packages/sqlalchemy/orm/", line 411, in _initialize_instance
    return manager.original_init(*mixed[1:], **kwargs)
  File "/usr/local/lib/python2.7/site-packages/airflow/", line 578, in __init__
    self.extra = extra
  File "<string>", line 1, in __set__
  File "/usr/local/lib/python2.7/site-packages/airflow/", line 639, in set_extra
    fernet = get_fernet()
  File "/usr/local/lib/python2.7/site-packages/airflow/", line 105, in get_fernet
    return Fernet(configuration.get('core', 'FERNET_KEY').encode('utf-8'))
  File "/usr/local/lib64/python2.7/site-packages/cryptography/", line 34, in __init__
    key = base64.urlsafe_b64decode(key)
  File "/usr/lib64/python2.7/", line 119, in urlsafe_b64decode
    return b64decode(s.translate(_urlsafe_decode_translation))
  File "/usr/lib64/python2.7/", line 78, in b64decode
    raise TypeError(msg)
TypeError: Incorrect padding

I also got an error when I try to add extras to a connection, if fernet_key is empty in the
config file. The error message was "Incorrect padding". Once I provided a valid key generated
with the instructions given [here|]
and restarted all of the airflow services it worked without any issues.

This message was sent by Atlassian JIRA

View raw message