mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
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 <krrish-berri-2@users.noreply.github.com>
This commit is contained in:
parent
f1f0a0bacd
commit
b2376e8359
1 changed files with 3 additions and 14 deletions
17
.github/scripts/close_duplicate_issues.py
vendored
17
.github/scripts/close_duplicate_issues.py
vendored
|
|
@ -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]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue