Skip to content

fix(scripts): paginate comments and reactions in auto-close-duplicates - #80508

Open
Serhii-Leniv wants to merge 1 commit into
anthropics:mainfrom
Serhii-Leniv:fix-autoclose-pagination
Open

fix(scripts): paginate comments and reactions in auto-close-duplicates#80508
Serhii-Leniv wants to merge 1 commit into
anthropics:mainfrom
Serhii-Leniv:fix-autoclose-pagination

Conversation

@Serhii-Leniv

Copy link
Copy Markdown

Fixes #80506

Problem

auto-close-duplicates.ts paginates the issues list, but its other two list reads rely on GitHub's default page size of 30 and never follow pagination:

  • the comments read feeding both the dupe-notice lookup and the commentsAfterDupe activity guard
  • the reactions read feeding the 👎 objection guard

sweep.ts in the same directory passes per_page=100 on every list call, so this is an outlier. The result is that the two guards protecting reporters from wrongful auto-close degrade exactly on high-engagement issues: a 👎 past the first 30 reactions is ignored (real dupe notices are already at 23 👎 — see the notice on #44252), and human objections after a dupe notice sitting at comment position 30 are invisible (notices deep in threads are a supported path via backfill-duplicate-comments.ts dispatch). This also composes with #79146/#79151 — counting any user's 👎 doesn't help if that 👎 is on page 2.

Fix

Add a githubRequestAllPages helper (per_page=100, follows pages until a short page, same 20-page safety cap as the existing issues loop) and use it for the comments and reactions reads. No behavior change for issues with ≤30 comments/reactions.

Testing

Mock-fetch harness emulating GitHub pagination semantics (30 items when per_page is absent), three fixture issues: author's -1 at reaction position 33 (#101), five human objections after a dupe notice at comment position 30 (#102), and a clean candidate (#103).

  • Script on main: closed: [101, 102, 103] — two wrongful closes
  • This branch: closed: [103] — objections honored, legitimate close still happens

This PR was written with the assistance of Claude Code; all changes were reviewed and the tests run by me.

Both reads used GitHub's default page size of 30 and never followed
pagination, unlike the issues list in the same script and every list
call in sweep.ts. A thumbs-down past the first 30 reactions, or human
replies after a dupe notice sitting at comment position 30, were
invisible to the guards, so issues auto-closed despite objections.

Add a githubRequestAllPages helper (per_page=100, follows pages until a
short page) and use it for both reads.

Fixes anthropics#80506
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto-close-duplicates.ts reads only the first 30 comments and 30 reactions, silently ignoring objections on busy issues

1 participant