Skip to content

Commit

Permalink
quick_setup: refactor faulty stage normalization
Browse files Browse the repository at this point in the history
Normalize and sort the faulty stages in one sweep.

Change-Id: I37b081278318da845b1fe514f2dcb4ee858e1306
  • Loading branch information
logan-connolly committed Feb 7, 2025
1 parent e4cb65f commit 12802e8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmk/gui/openapi/endpoints/quick_setup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 12802e8

Please sign in to comment.