Skip to content

Commit

Permalink
[AIRFLOW-1639] Fix Fernet error handling
Browse files Browse the repository at this point in the history
When the encrypted string cannot be decryted using
Fernet for some
reason, an error will be thrown. In Python 3.6.2
the .message attr
is not available. By casting the ValueError to a
string, the message
will be extracted from the Error.

Closes apache#2629 from Fokko/AIRFLOW-1639-fix-error-
handling

(cherry picked from commit aedf8de)
Signed-off-by: Bolke de Bruin <[email protected]>
  • Loading branch information
Fokko Driesprong authored and bolkedebruin committed Sep 24, 2017
1 parent 9ba73d7 commit 87df670
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions airflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def get_fernet():
try:
return Fernet(configuration.get('core', 'FERNET_KEY').encode('utf-8'))
except ValueError as ve:
raise AirflowException("Could not create Fernet object: {}"
.format(ve.message))
raise AirflowException("Could not create Fernet object: {}".format(ve))


if 'mysql' in settings.SQL_ALCHEMY_CONN:
Expand Down

0 comments on commit 87df670

Please sign in to comment.