Skip to content

fix(github): three GitHub list-pagination loops in backfill.ts have no page cap, unlike every sibling loop in the same file #8890

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

src/github/backfill.ts:4406's syncLabels (for (let page = 1; ; page += 1)) and :1790/:1845's supplementOpenIssuesFromGraphQl/supplementOpenPullRequestsFromGraphQl (both for (;;)) have no bound. Every other pagination loop in this file is explicitly bounded (PR_DETAIL_MAX_PAGES = 10, RECONCILE_OPEN_PRS_MAX_PAGES = 10, REVIEW_THREAD_MAX_PAGES = 10, PR_DETAIL_GRAPHQL_MAX_PAGES = 10), with comments stating the bound exists "so a pathological repo can't turn one webhook into an unbounded fetch loop." These three functions -- used to correct REST undercounts, i.e. triggered exactly for the largest/worst-behaved repos -- have neither a limit parameter nor a MAX_PAGES constant; termination depends entirely on GitHub eventually returning hasNextPage: false.

Requirements

Add a MAX_PAGES bound to all three loops, consistent with the file's existing 10-page convention, converging on a capped-style status/warning the same way githubPaged already does.

Deliverables

  • syncLabels has a MAX_PAGES bound matching the file's existing 10-page convention
  • supplementOpenIssuesFromGraphQl has the same bound
  • supplementOpenPullRequestsFromGraphQl has the same bound
  • A test for at least one of the three asserting the loop terminates at the cap (not merely relying on a mocked hasNextPage: false) and surfaces a capped signal

All of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.

Test Coverage Requirements

src/** -- 99%+ patch coverage, branch-counted, on all three new bounds.

Expected Outcome

A pathological repo triggering syncLabels or either GraphQL supplement function can no longer turn one call into an unbounded fetch loop, matching every other pagination loop in the same file.

Links & Resources

  • src/github/backfill.ts:1790,1845,4406

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions