From 7fb97963e05afe56a62cbe343cd1382f0f5cee9f Mon Sep 17 00:00:00 2001 From: hirokuni-kitahara Date: Fri, 16 Feb 2024 16:55:01 +0900 Subject: [PATCH] fix module search issue when the first cand is deprecated Signed-off-by: hirokuni-kitahara --- ansible_risk_insight/risk_assessment_model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ansible_risk_insight/risk_assessment_model.py b/ansible_risk_insight/risk_assessment_model.py index d862e3bc..f2e03fca 100644 --- a/ansible_risk_insight/risk_assessment_model.py +++ b/ansible_risk_insight/risk_assessment_model.py @@ -437,7 +437,11 @@ def search_module(self, name, exact_match=False, max_match=-1, collection_name=" # if any candidates don't match with FQCN, use the first index if not found_index: - found_index = self.module_index[short_name][0] + non_deprecated_cands = [idx for idx in self.module_index[short_name] if not idx["deprecated"]] + if non_deprecated_cands: + found_index = non_deprecated_cands[0] + else: + found_index = self.module_index[short_name][0] modules_json_list = [] if from_indices: