Skip to content

Commit

Permalink
Make checks for missing answers more strict
Browse files Browse the repository at this point in the history
Previously only presence of one section in the answerfile
has been verified, which led to false-positive preupgrade
reports when some other key has been present in the
dialog section instead of the required one.

OAMG-7521
  • Loading branch information
fernflower authored and pirat89 committed Sep 8, 2022
1 parent 866fcc8 commit 84de08e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions leapp/messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,17 @@ def request_stop_after_phase(self):
"""
self._stop_after_phase.set(True)

def _unanswered_questions(self, dialog):
userchoices = dialog.get_answers(self._answers)
res = [s for s in dialog.answerfile_sections.keys() if s.split('.', 2)[1] not in userchoices]
return res

def register_dialog(self, dialog, actor):
# FIXME(ivasilev) Make sure it works correctly in case of a dialog with several questions. Currently there
# is no such dialog in actors but this code should be revisited if this changes. OAMG-7523
self._dialogs.append(dialog)
userchoices = dialog.get_answers(self._answers)
if not userchoices:
unanswered = self._unanswered_questions(dialog)
if unanswered:
# produce DialogModel messages for all the dialogs that don't have answers in answerfile
stable_key = dialog.key if dialog.key else hashlib.sha1(
','.join(sorted(dialog.answerfile_sections.keys())).encode('utf-8')).hexdigest()
Expand All @@ -164,6 +171,7 @@ def register_dialog(self, dialog, actor):
key=stable_key), actor)
else:
# update dialogs with answers from answerfile. That is necessary for proper answerfile generation
userchoices = dialog.get_answers(self._answers)
for component, value in userchoices.items():
dialog_component = dialog.component_by_key(component)
if dialog_component:
Expand Down

0 comments on commit 84de08e

Please sign in to comment.