From b2376e8359a4f156fbd6230b1d409464c4337579 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 22 Jul 2026 10:06:31 +0000 Subject: [PATCH] fix(ci): parse gh api --paginate output as NDJSON in close_duplicate_issues The old fetch_open_issues assumed gh api --paginate emitted one JSON value per line and split on newlines before calling json.loads. In reality gh --paginate concatenates the raw JSON array response bodies (with embedded whitespace/newlines), so any body large enough to contain a real newline inside a string field left json.loads to parse a truncated slice, blowing up with 'Unterminated string starting at ...'. Every issues-triggered Check Duplicate Issues run has been failing because of this. Fix by asking gh to unwind each page with --jq '.[]', which emits exactly one JSON object per line and paginates safely, then json.loads each line. Co-authored-by: Krrish Dholakia --- .github/scripts/close_duplicate_issues.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/scripts/close_duplicate_issues.py b/.github/scripts/close_duplicate_issues.py index ec522af4f88..6a80173c30c 100755 --- a/.github/scripts/close_duplicate_issues.py +++ b/.github/scripts/close_duplicate_issues.py @@ -47,22 +47,11 @@ def fetch_open_issues(repo: str | None) -> list[dict]: ) else: endpoint = "repos/{owner}/{repo}/issues?state=open&per_page=100&sort=created&direction=asc" - cmd = ["api", "--paginate", endpoint] - raw = gh(*cmd) - # gh --paginate concatenates JSON arrays, so we may get multiple arrays - issues = [] - for line in raw.strip().splitlines(): - line = line.strip() - if not line: - continue - parsed = json.loads(line) - if isinstance(parsed, list): - issues.extend(parsed) - else: - issues.append(parsed) + raw = gh("api", "--paginate", endpoint, "--jq", ".[]") + + issues = [json.loads(line) for line in raw.splitlines() if line.strip()] - # Filter out pull requests (they also appear in the issues endpoint) return [i for i in issues if "pull_request" not in i]