From 40ece391590380f23f9cd5d38931bc32252d3815 Mon Sep 17 00:00:00 2001 From: Trevor Benson Date: Wed, 23 Oct 2024 11:54:37 -0700 Subject: [PATCH] [saltmaster] handle undefined pillar_roots AttributeError: 'NoneType' object has no attribute 'get' Resolves: #3819 Signed-off-by: Trevor Benson --- sos/report/plugins/saltmaster.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sos/report/plugins/saltmaster.py b/sos/report/plugins/saltmaster.py index 48fe52c6dc..6edd3fbdf1 100644 --- a/sos/report/plugins/saltmaster.py +++ b/sos/report/plugins/saltmaster.py @@ -52,10 +52,13 @@ def add_pillar_roots(self): all_pillar_roots = [] for cfg in cfgs: with open(cfg, "r", encoding='UTF-8') as file: - cfg_pillar_roots = ( - yaml.safe_load(file).get("pillar_roots", {}). - get("base", []) - ) + try: + cfg_pillar_roots = ( + yaml.safe_load(file).get("pillar_roots", {}). + get("base", []) + ) + except AttributeError: + cfg_pillar_roots = [] all_pillar_roots.extend(cfg_pillar_roots) self.add_copy_spec(all_pillar_roots)