-
Notifications
You must be signed in to change notification settings - Fork 479
fix: stop unbounded pagination in check_rate_limit when run exceeds threshold #48972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9a78ec5
90a70a5
07a37bd
27fbb3a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,11 +156,12 @@ async function main() { | |
| break; | ||
| } | ||
|
|
||
| // Skip if run is older than the time window | ||
| // Stop if run is older than the time window (runs are newest-first) | ||
| const runCreatedAt = new Date(run.created_at); | ||
| if (runCreatedAt < thresholdTime) { | ||
| core.info(` Skipping run ${run.id} - created before threshold (${run.created_at})`); | ||
| continue; | ||
| core.info(` Stopping pagination - run ${run.id} created before threshold (${run.created_at})`); | ||
| hasMore = false; | ||
| break; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] The existing test 💡 Suggested regression testit("should stop pagination when a run predates the threshold", async () => {
// First page has one stale run (older than window)
mockGithub.rest.actions.listWorkflowRuns
.mockResolvedValueOnce({
data: {
workflow_runs: [{
id: 999,
run_number: 1,
created_at: new Date(Date.now() - 120 * 60 * 1000).toISOString(),
actor: { login: "test-user" },
status: "completed",
}],
},
})
.mockResolvedValue({ data: { workflow_runs: [] } });
await checkRateLimit.main();
// Must only call once — page 2 should never be fetched
expect(mockGithub.rest.actions.listWorkflowRuns).toHaveBeenCalledTimes(1);
expect(mockCore.info).toHaveBeenCalledWith(
expect.stringContaining("Stopping pagination")
);
});Without this, a future @copilot please address this. |
||
| } | ||
|
|
||
| // Check if run is by the same actor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct fix logically, but no regression test was added for this exact incident (unbounded pagination when a run predates the threshold) — the bug that caused a 37% failure rate for 6h will have no test guarding against reintroduction.
💡 Add a targeted test
The fix relies on the undocumented-in-code assumption that
listWorkflowRunsreturns runs newest-first (true by API default, but not enforced/asserted anywhere). A test mocking a paginated response where an early run in page 1 is older thanthresholdTime, followed by mock pages that would need many more calls if pagination continued, would catch a future regression tocontinueand also validate this ordering assumption. Consider assertinggithub.rest.actions.listWorkflowRunsis called exactly once in that scenario.