Skip to content

Commit

Permalink
Wrap getter in a try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
xyu committed Feb 17, 2022
1 parent 027a758 commit d85ac8e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def as_dict(
if include_secret:
self._include_secrets(config_sources, display_sensitive, display_source, raw)
else:
self._filter_by_source(config_sources, display_source, self._get_env_var_option)
self._filter_by_source(config_sources, display_source, self._get_secret_option)

return config_sources

Expand Down Expand Up @@ -718,11 +718,16 @@ def _include_envs(self, config_sources, display_sensitive, display_source, raw):

def _filter_by_source(self, config_sources, display_source, getter_func):
for (section, key) in self.sensitive_config_values:
opt = getter_func(section, key)
if not opt:
continue
# Don't bother if we don't have section / key
if section not in config_sources or key not in config_sources[section]:
continue
# Check that there is something to override defaults
try:
opt = getter_func(section, key)
except ValueError:
continue
if not opt:
continue
if display_source:
opt, source = config_sources[section][key]
else:
Expand Down

0 comments on commit d85ac8e

Please sign in to comment.