Skip to content

fix(sweep): paginate the Dependabot alerts fetch - #137

Merged
toufali merged 4 commits into
mainfrom
fix/sweep-paginate-alerts
Aug 21, 2026
Merged

fix(sweep): paginate the Dependabot alerts fetch#137
toufali merged 4 commits into
mainfrom
fix/sweep-paginate-alerts

Conversation

@toufali

@toufali toufali commented Aug 21, 2026

Copy link
Copy Markdown
Member

Fixes #136.

check_alerts requested per_page=100 and used only the first page, so repos with >100 open alerts (mozilla/fxa has 194) had the rest never investigated — confirmed live: 100 of 194 investigated, 94 invisible.

Paginate until a page returns <100. Added a >100-alert regression test.

check_alerts requested only per_page=100 and used the first page, so repos
with >100 open alerts (e.g. mozilla/fxa at 194) had the rest silently
invisible — never investigated. Loop through all pages until a short page.
Added a >100-alert pagination test.

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

Paginates Dependabot alert discovery so repositories with over 100 open alerts are fully processed.

Changes:

  • Fetches alert pages until reaching a short or empty page.
  • Adds a regression test covering 105 alerts.

Reviewed changes

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

File Description
scripts/sweep.py Implements paginated alert fetching.
tests/scripts/test_sweep.py Adds pagination regression coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/scripts/test_sweep.py
With pagination removed, a sweep could dispatch all of a repo's alerts at
once (fxa: 194) — a cost/concurrency spike. Add two safeguards:
- investigate.max_per_sweep (default 50): per-repo cap; the rest drain on
  later sweeps (stateless — tagged alerts are skipped next time).
- INVESTIGATE_TOTAL_CAP (200): global backstop across all repos per run.
Per-alert budget is unchanged.
The pagination test only checked call count; a regression fetching page 1
twice would still pass. Assert the recorded page params are ['1','2'].

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 3 out of 3 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

scripts/sweep.py:607

  • This failure path falls through to the successful end-of-pagination handling. A page-1 failure is therefore followed by “No open Dependabot alerts,” while a later-page failure reports the partial data length as the total found; both messages misrepresent an API failure. Keep fetch failures distinct from an empty/complete response (and explicitly decide whether partial pages should still be dispatched).
        except Exception as e:
            print(f"    Could not fetch alerts (page {page}): {e}")
            break

Comment thread scripts/sweep.py Outdated
The global INVESTIGATE_TOTAL_CAP path in main() was untested. Extract it into
cap_investigations(actions, cap) and cover over-cap (200 kept, non-investigate
actions preserved), exact-boundary, and under-cap cases.
@toufali
toufali force-pushed the fix/sweep-paginate-alerts branch from e0561dd to 098b47c Compare August 21, 2026 18:26
@toufali
toufali merged commit 1b1b676 into main Aug 21, 2026
9 checks passed
@toufali
toufali deleted the fix/sweep-paginate-alerts branch August 21, 2026 19:26
toufali added a commit that referenced this pull request Aug 21, 2026
fix(sweep): cursor pagination for Dependabot alerts (hotfix for #137)
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.

sweep only investigates the first 100 alerts — check_alerts doesn't paginate

2 participants