fix(sweep): cursor pagination for Dependabot alerts (hotfix for #137) - #138
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes Dependabot alert pagination by replacing unsupported page-based pagination with cursor pagination.
Changes:
- Parses the next cursor from GitHub’s
Linkheader. - Updates pagination tests for cursor semantics.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
scripts/sweep.py |
Implements cursor-based alert pagination. |
tests/scripts/test_sweep.py |
Updates the pagination regression test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
toufali
force-pushed
the
fix/sweep-cursor-pagination
branch
3 times, most recently
from
August 21, 2026 20:53
e5bba92 to
5bc1fe2
Compare
check_alerts previously fetched only the first 100 open alerts. The Dependabot alerts API uses cursor pagination (Link rel="next" with an 'after' cursor), not the page parameter — passing ?page=N returns 400. Follow the Link cursor, decoding it first: it arrives URL-encoded and PyGithub re-encodes params, so a raw cursor would double-encode and 400 on page 2. Guard against a runaway cursor two ways — break as soon as a cursor recurs (with a 100-page numeric backstop), and dedupe alerts by number so a re-served page can't emit duplicate investigations. Tests cover multi-page fetch with an encoded cursor and the repeating-cursor case.
toufali
force-pushed
the
fix/sweep-cursor-pagination
branch
from
August 21, 2026 21:02
5bc1fe2 to
64916c4
Compare
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.
Regression from #137 — alert fetching is broken for all repos right now.
#137 added
?page=Npagination, but the Dependabot alerts API doesn't support page-based paging:So every fetch fails on page 1 →
No open Dependabot alerts→ 0 investigations dispatched (every repo). Seen live in the latest sweeps for mozilla/fxa (0 of 194).Fix: use the API's cursor pagination — follow the
aftercursor from the Link header'srel="next". Verified the parser against realistic Link headers (cursor-not-last, prev-only last page, empty). Per-sweep/global caps unchanged. Test rewritten for cursor semantics.