Skip to content

fix(gh): resolve infinite pagination loop and unhandled timeout in _build_paginated_url and run_gh #228

Closed

Description

@dan-petty

Problem Description

When run_gh processes paginated API requests (such as devops gh project sync fetching repository issues via repos/{repo}/issues?state=all&per_page=100), _build_paginated_url checks if "page=" in endpoint:. Because "per_page=100" contains "page=", it executes re.sub(r"([?&])page=\d+", rf"\g<1>page={page}", endpoint).

However, r"([?&])page=\d+" does NOT match per_page=100 (the preceding character is _, not ? or &). As a result:

  1. _build_paginated_url returns the original endpoint unchanged without appending &page=1 or &page=2.
  2. Every pagination iteration repeatedly fetches page 1.
  3. len(data) < per_page is never satisfied, trapping execution in an infinite pagination loop that burns hundreds of API requests over hours until a subprocess timeout or rate limit exhaustion occurs.
  4. run_subprocess does not catch subprocess.TimeoutExpired when check=False, allowing the timeout exception to escape unhandled.

Root Cause

  • In src/devops_cli/github/rate_limiter.py:826, if "page=" in endpoint: falsely triggers on per_page=.
  • _run_gh_paginated lacks a safety cap on maximum pages (MAX_PAGINATED_PAGES).
  • run_subprocess does not trap subprocess.TimeoutExpired when check=False to return a CompletedProcess(returncode=124).

Remediation Plan

  1. Update _build_paginated_url in src/devops_cli/github/rate_limiter.py to use re.search(r"([?&])page=\d+", endpoint).
  2. Introduce a maximum page boundary (CONST_MAX_PAGINATION_PAGES = 500 or similar) in _run_gh_paginated.
  3. Update run_subprocess in src/devops_cli/core/process.py to catch subprocess.TimeoutExpired when check=False and record telemetry.
  4. Add unit tests for _build_paginated_url with per_page query parameters and timeout containment.

Activity

  1. added this to the v0.2.19 milestone on Sep 17, 2026
  2. added
    type/bug
    scope/cli
    priority/p1-high
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/clitype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions