Skip to content

Commit

Permalink
[AIRFLOW-2938] Handle improperly formatted extra field in connection …
Browse files Browse the repository at this point in the history
…gracefully (#3785)
  • Loading branch information
wrp authored and Tao Feng committed Aug 23, 2018
1 parent c9fec7a commit fc10f7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion airflow/hooks/http_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions airflow/www_rbac/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit fc10f7e

Please sign in to comment.