fix: use Cloudflare Pages API default per_page for pagination#305
fix: use Cloudflare Pages API default per_page for pagination#305
Conversation
Cloudflare Pages deployments API rejects per_page=100 when combined with the page parameter. Use per_page=25 (the documented default) to stay within API limits while still paginating correctly.
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughUpdates the GitHub Actions workflow for Cloudflare Pages previews to introduce a configurable Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Comment |
Greptile SummaryThis PR is a targeted bug fix for the Key changes:
The fix is minimal, correct, and low-risk. The trade-off is that Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant GHA as GitHub Actions<br/>(cleanup-preview job)
participant CF as Cloudflare Pages API
GHA->>GHA: Set PER_PAGE=25, PAGE=1, DEPLOYMENTS=""
loop Until page is incomplete
GHA->>CF: GET /deployments?per_page=25&page=PAGE
CF-->>GHA: HTTP 200 + JSON body
GHA->>GHA: Extract matching deployment IDs for branch
GHA->>GHA: PAGE_COUNT = length of .result
alt PAGE_COUNT < PER_PAGE (25)
GHA->>GHA: break (last page reached)
else PAGE_COUNT == PER_PAGE
GHA->>GHA: PAGE++, continue
end
end
loop For each deployment ID
GHA->>CF: DELETE /deployments/{id}?force=true
CF-->>GHA: HTTP 200 (or 4xx for most-recent-deployment restriction)
end
GHA->>GHA: echo "Deleted N preview deployments"
Last reviewed commit: 290e983 |
There was a problem hiding this comment.
Pull request overview
Updates the Cloudflare Pages preview cleanup workflow pagination to avoid an API 400 error caused by combining page with per_page=100, aligning the request with Cloudflare’s documented default page size.
Changes:
- Introduces a
PER_PAGE=25variable for Cloudflare Pages deployments pagination. - Updates the list deployments request to use
per_page=${PER_PAGE}instead of100. - Adjusts the pagination termination condition to use
PER_PAGErather than a hardcoded value.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
.github/workflows/pages-preview.yml
Outdated
|
|
||
| # Paginate through all deployments for this branch | ||
| # Note: Cloudflare prevents deleting the most recent deployment per project — that one will remain | ||
| # Cloudflare Pages API rejects per_page=100 with page param; use default (25) |
There was a problem hiding this comment.
The new comment says we “use default (25)”, but the script still explicitly sets per_page=${PER_PAGE}. Consider rewording to clarify that we’re explicitly using Cloudflare’s documented default value (25), not omitting the parameter (the actual API default behavior).
| # Cloudflare Pages API rejects per_page=100 with page param; use default (25) | |
| # Cloudflare Pages API rejects per_page=100 with page param; explicitly use documented default page size (25) |
🤖 I have created a release *beep* *boop* --- ## [0.1.1](v0.1.0...v0.1.1) (2026-03-11) ### Features * add PR preview deployments via Cloudflare Pages ([#302](#302)) ([b73c45a](b73c45a)) ### Bug Fixes * correct deploy-pages SHA and improve preview cleanup reliability ([#304](#304)) ([584d64a](584d64a)) * harden API key hashing with HMAC-SHA256 and clean up legacy changelog ([#292](#292)) ([5e85353](5e85353)) * upgrade upload-pages-artifact to v4 and add zizmor workflow linting ([#299](#299)) ([2eac571](2eac571)) * use Cloudflare Pages API default per_page for pagination ([#305](#305)) ([9fec245](9fec245)) ### Documentation * remove milestone references and rebrand to SynthOrg ([#289](#289)) ([57a03e0](57a03e0)) * set up documentation site, release CI, and sandbox hardening ([#298](#298)) ([0dec9da](0dec9da)) * split DESIGN_SPEC.md into 7 focused design pages ([#308](#308)) ([9ea0788](9ea0788)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Signed-off-by: Aurelio <19254254+Aureliolo@users.noreply.github.com>
Summary
per_page=100when combined with thepageparameter (HTTP 400: "Invalid list options provided")per_page=25(Cloudflare's documented default) via aPER_PAGEvariable100Context: The pagination was added in #304 to handle PRs with >100 deployments. The cleanup job failed on first run because
per_page=100&page=1is rejected by the Cloudflare API. This was correctly surfaced asexit 1(previously would have been silently swallowed).Test plan