From e942d1e9e4c53ebeb2b366326a65facf3f7848ac Mon Sep 17 00:00:00 2001 From: Guilherme Gallo Date: Fri, 30 May 2025 02:41:08 -0300 Subject: [PATCH] bin/ci: crnm: Sanitize n_colums value The number of columns should never be less than 1, otherwise we can break the script such as: ``` Traceback (most recent call last): File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 734, in main() File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 713, in main target_job_id, ret, exec_t = monitor_pipeline( ^^^^^^^^^^^^^^^^^ File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 221, in monitor_pipeline cancel_jobs(project, to_cancel) File "/var/home/guilherme/projects/mesa/bin/ci/ci_run_n_monitor.py", line 400, in cancel_jobs print_formatted_list(cancelled_jobs, indentation=8) File "/var/home/guilherme/projects/mesa/bin/ci/gitlab_gql.py", line 373, in print_formatted_list step = (len(elements) // n_columns) + 1 ~~~~~~~~~~~~~~^^~~~~~~~~~~ ZeroDivisionError: integer division or modulo by zero ``` Part-of: --- bin/ci/gitlab_gql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ci/gitlab_gql.py b/bin/ci/gitlab_gql.py index 25fc7ba7873..efc2da3477a 100755 --- a/bin/ci/gitlab_gql.py +++ b/bin/ci/gitlab_gql.py @@ -369,7 +369,7 @@ def print_formatted_list(elements: list[str], indentation: int = 0) -> None: return column_separator_size = 2 column_width: int = len(max(elements, key=len)) + column_separator_size - n_columns: int = (h_size - indentation) // column_width + n_columns: int = max((h_size - indentation) // column_width, 1) step = (len(elements) // n_columns) + 1 rows = [elements[i::step] for i in range(step)] for line in rows: