🐛 fix: fetch all pages data to avoid bypass check fail#30
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that all paginated API endpoints retrieve every page of data, preventing incomplete event or label checks.
- Introduce a reusable
withAllPageshelper inutils.tsfor full pagination. - Replace single-page
octokitcalls withwithAllPagesinlabel.ts,comment.ts, andapprove.ts. - Adjust response handling to work directly with arrays instead of
.datawrappers.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/rules/utils.ts | Added withAllPages helper and Response interface to abstract pagination logic. |
| src/rules/label.ts | Swapped listEvents and listLabelsOnIssue for withAllPages and removed .data usage. |
| src/rules/comment.ts | Replaced listComments with withAllPages, mapping directly over the returned array. |
| src/rules/approve.ts | Updated listReviews to use withAllPages and flattened the result into an array. |
Comments suppressed due to low confidence (5)
src/rules/utils.ts:86
- Add JSDoc above
withAllPagesto explain the purpose, parameters, and return value of the helper.
export function withAllPages<T, U>(
src/rules/utils.ts:86
- Add unit tests to verify
withAllPagescorrectly accumulates items across multiple pages, including edge cases.
export function withAllPages<T, U>(
src/rules/label.ts:33
- [nitpick] Rename
allEventsResponseto something likeallEventsto reflect that this variable is now an array, not an API response object.
const allEventsResponse = await withAllPages(
src/rules/label.ts:41
- [nitpick] Rename
allLabelsResponsetoallLabelsto avoid confusion since it contains a flat array of label objects.
const allLabelsResponse = await withAllPages(
src/rules/approve.ts:27
- [nitpick] Rename
allReviewResponsetoallReviewsorreviewsto reflect that it holds an array of review records.
const allReviewResponse = await withAllPages(
src/rules/comment.ts
Outdated
Comment on lines
42
to
46
| const allCommentResponseOld = await octokit.rest.issues.listComments({ | ||
| owner, | ||
| repo, | ||
| issue_number: number, | ||
| }) |
There was a problem hiding this comment.
Remove the unused allCommentResponseOld call to avoid redundant API requests and dead code.
Suggested change
| const allCommentResponseOld = await octokit.rest.issues.listComments({ | |
| owner, | |
| repo, | |
| issue_number: number, | |
| }) | |
| // Removed unused allCommentResponseOld variable and its associated API call. |
Contributor
Author
|
/bypass all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
每个 REST API 都获取全部 pages 以免部分 event 缺失导致匹配失败