airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRFLOW-2938) Invalid 'extra' field in connection can raise an AttributeError when attempting to edit
Date Thu, 23 Aug 2018 22:45:00 GMT

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

ASF GitHub Bot commented on AIRFLOW-2938:
-----------------------------------------

feng-tao closed pull request #3785: [AIRFLOW-2938] Handle improperly formatted extra field
in connection …
URL: https://github.com/apache/incubator-airflow/pull/3785
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/airflow/hooks/http_hook.py b/airflow/hooks/http_hook.py
index c449fe0c15..caa89d3142 100644
--- a/airflow/hooks/http_hook.py
+++ b/airflow/hooks/http_hook.py
@@ -70,7 +70,11 @@ def get_conn(self, headers=None):
         if conn.login:
             session.auth = (conn.login, conn.password)
         if conn.extra:
-            session.headers.update(conn.extra_dejson)
+            try:
+                session.headers.update(conn.extra_dejson)
+            except TypeError:
+                self.log.warn('Connection to {} has invalid extra field.'.format(
+                    conn.host))
         if headers:
             session.headers.update(headers)
 
diff --git a/airflow/www_rbac/views.py b/airflow/www_rbac/views.py
index 3ab872d5b1..d011724cc6 100644
--- a/airflow/www_rbac/views.py
+++ b/airflow/www_rbac/views.py
@@ -1922,6 +1922,11 @@ def prefill_form(self, form, pk):
         except Exception:
             d = {}
 
+        if not hasattr(d, 'get'):
+            logging.warning('extra field for {} is not iterable'.format(
+                form.data.get('conn_id', '<unknown>')))
+            return
+
         for field in self.extra_fields:
             value = d.get(field, '')
             if value:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Invalid 'extra' field in connection can raise an AttributeError when attempting to edit
> ---------------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-2938
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2938
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: William Pursell
>            Assignee: William Pursell
>            Priority: Minor
>
> When the extra field of a connection is not an iterable json object, attempting to edit
the connection can lead to a stack trace "Ooops": 
> AttributeError: 'NoneType' object has no attribute 'get'



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message