From 12802e8c67e8ceb4a4e4b223b8df767ce62aee4f Mon Sep 17 00:00:00 2001 From: Logan Connolly Date: Fri, 7 Feb 2025 10:48:45 +0100 Subject: [PATCH] quick_setup: refactor faulty stage normalization Normalize and sort the faulty stages in one sweep. Change-Id: I37b081278318da845b1fe514f2dcb4ee858e1306 --- cmk/gui/openapi/endpoints/quick_setup/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cmk/gui/openapi/endpoints/quick_setup/__init__.py b/cmk/gui/openapi/endpoints/quick_setup/__init__.py index e57be7d6126..fe2ed73fe54 100644 --- a/cmk/gui/openapi/endpoints/quick_setup/__init__.py +++ b/cmk/gui/openapi/endpoints/quick_setup/__init__.py @@ -465,17 +465,16 @@ def _add_summary_error_message( all_stage_errors: list[ValidationErrors] = [] all_stage_errors.extend(current_errors) - faulty_stage_indices = [ + normalized_faulty_stage_indices = sorted( err.stage_index + 1 for err in current_errors if err.stage_index is not None - ] - faulty_stage_indices.sort() + ) msg = ( _("Stages %s contain invalid form data. Please correct them and try again.") - % ", ".join(str(index) for index in faulty_stage_indices) - if len(faulty_stage_indices) > 1 + % ", ".join(str(index) for index in normalized_faulty_stage_indices) + if len(normalized_faulty_stage_indices) > 1 else _("Stage %s contains invalid form data. Please correct them and try again.") - % faulty_stage_indices[0] + % normalized_faulty_stage_indices[0] ) all_stage_errors.append(