From d85ac8e9c446e6da1b2149b168aa3a75c55a63db Mon Sep 17 00:00:00 2001 From: Xiao Yu Date: Thu, 17 Feb 2022 21:15:41 +0000 Subject: [PATCH] Wrap getter in a try/catch --- airflow/configuration.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/airflow/configuration.py b/airflow/configuration.py index e66c40a0fec4d..861b60799c9ed 100644 --- a/airflow/configuration.py +++ b/airflow/configuration.py @@ -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 @@ -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: