From 846e60a3194e1dcac9c2468f357238f4dc24e93e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 19 May 2026 19:51:21 +0000 Subject: [PATCH] fix(ci): use --jq '.[]' to flatten gh api --paginate output The check-duplicate workflow's auto-close step failed with: json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 2856598 `gh api --paginate` without --jq concatenates each page's response as a pretty-printed JSON array spanning many lines; splitting that on newlines and feeding individual lines to json.loads cannot work. Pass --jq '.[]' so each issue is emitted as a single line of JSON, which the line-by-line parser handles correctly. Co-authored-by: Krrish Dholakia --- .github/scripts/close_duplicate_issues.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/scripts/close_duplicate_issues.py b/.github/scripts/close_duplicate_issues.py index ec522af4f88..87ae8051125 100755 --- a/.github/scripts/close_duplicate_issues.py +++ b/.github/scripts/close_duplicate_issues.py @@ -47,20 +47,19 @@ 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] + # Use --jq '.[]' so each page is flattened to one JSON object per line. + # Without --jq, gh prints each page as a pretty-printed JSON array spanning + # many lines, and across multiple pages the arrays are concatenated — which + # is not parseable as a single JSON document nor as line-delimited JSON. + cmd = ["api", "--paginate", endpoint, "--jq", ".[]"] raw = gh(*cmd) - # gh --paginate concatenates JSON arrays, so we may get multiple arrays issues = [] - for line in raw.strip().splitlines(): + for line in raw.splitlines(): line = line.strip() if not line: continue - parsed = json.loads(line) - if isinstance(parsed, list): - issues.extend(parsed) - else: - issues.append(parsed) + issues.append(json.loads(line)) # Filter out pull requests (they also appear in the issues endpoint) return [i for i in issues if "pull_request" not in i]