[ 
https://issues.apache.org/jira/browse/AIRFLOW-1516?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16133422#comment-16133422
 ] 

ASF subversion and git services commented on AIRFLOW-1516:
----------------------------------------------------------

Commit d22340aab01ed684c6b056f2b54f60e0602cabd6 in incubator-airflow's branch 
refs/heads/master from [~erod]
[ https://git-wip-us.apache.org/repos/asf?p=incubator-airflow.git;h=d22340a ]

[AIRFLOW-1516] Fix error handling getting fernet

There were unhandled cases for exceptions when
importing fernet in
models.py. This seems to be a remanent of a
previous refactor,
replacing logic that would depend on the
definition of a global variable
for Fernet if it was imported correctly.

Generally catching all exceptions from get_fernet
function, given that
other functions are already handling it that way
and the only
error handling case here is to not use encryption.

Closes #2527 from edgarRd/erod-fernet-error-
handling


> Potential uncaught errors when getting fernet object in airflow/models.py
> -------------------------------------------------------------------------
>
>                 Key: AIRFLOW-1516
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1516
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: Edgar Rodriguez
>            Assignee: Edgar Rodriguez
>
> There are unhandled cases for exceptions when importing fernet in 
> `models.py`. This seems to be a remanent of a previous refactor, replacing 
> logic that would depend on the definition of a global variable for Fernet if 
> it was imported correctly.
> Lazy-loading fernet into a function won't have the same behavior and would 
> raise an ImportError instead.
> Code like: 
> {code}
>     def set_val(self, value):
>         if value:
>             try:
>                 fernet = get_fernet()
>                 self._val = fernet.encrypt(bytes(value, 'utf-8')).decode()
>                 self.is_encrypted = True
>             except NameError:
>                 self._val = value
>                 self.is_encrypted = False
> {code}
> won't catch the right exception since it won't raise {{NameError}}, letting 
> it bubble leading to undetermined behavior.
> Remediation would be to either catch the right exceptions coming out of 
> {{get_fernet()}} function or generally catch all exceptions , given that it's 
> the way other functions are already handling it and the only error handling 
> case here is to not use encryption anyways. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to