From f7987679dda5394e0dcc13964742deeef01532bf Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 13 Oct 2026 00:45:57 +0200 Subject: [PATCH] fix(ci): read every page of the job listing before reporting failed roles report_failures asked `gh api --paginate` for the run's jobs with the jq filter `[.jobs[] | {name, conclusion}]`. gh applies that filter to each page and prints one array per page, so a run with more jobs than one page holds produced two JSON documents, and json.loads stopped with "Extra data: line 2 column 1". Main run 38218402254 (113 jobs) failed its "Report main role failures" job that way, and no issue was opened for its failed roles. The listing now emits one job object per line and parses the lines one by one, the same way logs/download/github.py lists jobs. Verified: the old parse of the real output of run 38218402254 raises the same "Extra data: line 2 column 1 (char 8491)" as CI; list_jobs on that run returns all 113 jobs, 16 of them failed, grouped into 12 failed roles. Co-Authored-By: Claude Opus 5.5 (1M context) --- cli/meta/ci/report_failures.py | 26 ++++++++++--------- .../cli/meta/ci/test_report_failures.py | 15 +++++++++++ 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/cli/meta/ci/report_failures.py b/cli/meta/ci/report_failures.py index b8721a80a7..2121f104a4 100644 --- a/cli/meta/ci/report_failures.py +++ b/cli/meta/ci/report_failures.py @@ -148,19 +148,21 @@ def _existing_issue(repo: str, role: str) -> int | None: return None -def report(run_id: str, repo: str) -> int: - jobs = json.loads( - _gh( - [ - "api", - "--paginate", - f"repos/{repo}/actions/runs/{run_id}/jobs", - "--jq", - "[.jobs[] | {name, conclusion}]", - ] - ) - or "[]" +def list_jobs(run_id: str, repo: str) -> list[dict]: + out = _gh( + [ + "api", + "--paginate", + f"repos/{repo}/actions/runs/{run_id}/jobs", + "--jq", + ".jobs[] | {name, conclusion}", + ] ) + return [json.loads(line) for line in out.splitlines() if line.strip()] + + +def report(run_id: str, repo: str) -> int: + jobs = list_jobs(run_id, repo) roles = failed_roles(jobs) if not roles: print("No failed deploy roles.") diff --git a/tests/unit/python/cli/meta/ci/test_report_failures.py b/tests/unit/python/cli/meta/ci/test_report_failures.py index 557e2bcdd3..f5a0627373 100644 --- a/tests/unit/python/cli/meta/ci/test_report_failures.py +++ b/tests/unit/python/cli/meta/ci/test_report_failures.py @@ -3,6 +3,7 @@ from __future__ import annotations import tempfile import unittest from pathlib import Path +from unittest.mock import patch from cli.meta.ci.report_failures import ( Failure, @@ -10,6 +11,7 @@ from cli.meta.ci.report_failures import ( decisive_excerpt, failed_roles, issue_body, + list_jobs, ) @@ -80,6 +82,19 @@ class TestReportFailures(unittest.TestCase): artifact_name("web-app-x", Failure("compose", "0", True, "fedora", "zfs")), ) + def test_list_jobs_reads_one_job_per_line_across_pages(self) -> None: + pages = ( + '{"name": "deploy a", "conclusion": "success"}\n' + '{"name": "deploy b", "conclusion": "failure"}\n' + ) + with patch("cli.meta.ci.report_failures._gh", return_value=pages): + jobs = list_jobs("1", "owner/repo") + self.assertEqual([job["name"] for job in jobs], ["deploy a", "deploy b"]) + + def test_list_jobs_of_an_empty_listing_is_empty(self) -> None: + with patch("cli.meta.ci.report_failures._gh", return_value=""): + self.assertEqual(list_jobs("1", "owner/repo"), []) + def test_issue_body_lists_failures_and_run(self) -> None: body = issue_body( "web-app-xwiki",