Skip to content

run_gh_api(paginate=True) breaks on >1 page: JSONDecodeError from concatenated pages, --slurp incompatible with jq= #41

Description

@cbeaulieu-gt

Summary

Flagged by CodeRabbit on PR #39 (inline comment, scripts/gh-create-issue-context.py:87), declined as out-of-scope for that PR because the bug lives in pre-existing shared code, not anything #39 introduced.

run_gh_api(paginate=True) in scripts/_gh_common.py passes gh api --paginate and parses stdout with a single json.loads() call. gh api --paginate (without --slurp) emits one JSON value per page, concatenated — so any response spanning more than one page raises JSONDecodeError: Extra data.

CodeRabbit's proposed fix: use --slurp to wrap all pages into a single outer array, then flatten. Caveat: --slurp is mutually exclusive with --jq — any paginate=True call site that also passes jq= needs that jq filtering moved to post-processing.

Affected call sites

run_gh_api(paginate=True) is used identically (no --slurp) by:

  • scripts/gh-create-issue-context.py
  • scripts/gh-summary.py
  • scripts/gh-quick-wins.py
  • scripts/gh-refresh-issues.py
  • scripts/gh-release-status.py

All are exposed to this bug whenever a paginated query actually spans more than one page.

Suggested fix

  • Add --slurp in run_gh_api when paginate=True.
  • Flatten the resulting array-of-page-arrays before returning.
  • Audit call sites for paginate=True combined with jq= and move that filtering to Python-side post-processing.
  • Add a two-page regression test (this is what exposed the gap — CodeRabbit's repro used a JSON round-trip probe, not a live multi-page fetch).

🤖 Generated by Claude Code on behalf of @cbeaulieu-gt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions