Skip to content

fix(sweep): cursor pagination for Dependabot alerts (hotfix for #137) - #138

Merged
toufali merged 1 commit into
mainfrom
fix/sweep-cursor-pagination
Aug 21, 2026
Merged

fix(sweep): cursor pagination for Dependabot alerts (hotfix for #137)#138
toufali merged 1 commit into
mainfrom
fix/sweep-cursor-pagination

Conversation

@toufali

@toufali toufali commented Aug 21, 2026

Copy link
Copy Markdown
Member

Regression from #137 — alert fetching is broken for all repos right now.

#137 added ?page=N pagination, but the Dependabot alerts API doesn't support page-based paging:

Could not fetch alerts (page 1): Pagination using the `page` parameter is not supported.: 400

So every fetch fails on page 1 → No open Dependabot alerts0 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 after cursor from the Link header's rel="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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Dependabot alert pagination by replacing unsupported page-based pagination with cursor pagination.

Changes:

  • Parses the next cursor from GitHub’s Link header.
  • 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.

Comment thread scripts/sweep.py Outdated
@toufali
toufali force-pushed the fix/sweep-cursor-pagination branch 3 times, most recently from e5bba92 to 5bc1fe2 Compare August 21, 2026 20:53
@toufali
toufali requested a balanced review from Copilot August 21, 2026 20:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread scripts/sweep.py
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
toufali force-pushed the fix/sweep-cursor-pagination branch from 5bc1fe2 to 64916c4 Compare August 21, 2026 21:02
@toufali
toufali requested a balanced review from Copilot August 21, 2026 21:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@toufali
toufali merged commit 9b9132b into main Aug 21, 2026
10 checks passed
@toufali
toufali deleted the fix/sweep-cursor-pagination branch August 21, 2026 21:06
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.

2 participants