0
votes

In the Airflow admin site

When I update the http_default connection the http sensor gives the following error:

ERROR - Could not create Fernet object: Incorrect padding

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 173, in get_fernet _fernet = Fernet(fernet_key.encode('utf-8')) File "/usr/local/lib/python3.6/site-packages/cryptography/fernet.py", line 35, in init key = base64.urlsafe_b64decode(key) File "/usr/local/lib/python3.6/base64.py", line 133, in urlsafe_b64decode return b64decode(s) File "/usr/local/lib/python3.6/base64.py", line 87, in b64decode return binascii.a2b_base64(s) binascii.Error: Incorrect padding

1

1 Answers

0
votes

It seems your $FERNET_KEY is not set.

  • Can you check the output of echo $FERNET_KEY?
  • Can you also check the fernet_key = entry in your airflow.cfg?

If those are empty, you can generate a new one with some Python code:

from cryptography.fernet import Fernet
print(Fernet.generate_key().decode())

Then set this value in your airflow.cfg under fernet_key =.
Alternatively you can also set it via export AIRFLOW__CORE__FERNET_KEY=your_fernet_key (this gives you more flexibility if you are building your environment dynamically).

Important to keep in mind
The Fernet Key is used to encrypt your connections' credentials, so you need to keep it safe it you want to be able to decrypt them later. If you had created some connections before with another fernet key, and you generated a new one as described above, your old connections won't work and will have to be recreated once you set the new key in place.