Skip to content

fix(review): paginate check-runs in findPreviewUrlFromChecks - #7881

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
davion-knight:fix-preview-url-paginate-checks
Jul 21, 2026
Merged

fix(review): paginate check-runs in findPreviewUrlFromChecks#7881
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
davion-knight:fix-preview-url-paginate-checks

Conversation

@davion-knight

Copy link
Copy Markdown
Contributor

Problem

findPreviewUrlFromChecks (src/review/visual/preview-url.ts) fetched only page 1 of a head SHA's check-runs (?per_page=100) and never followed pagination — while its two siblings in the same file, getPreviewBuildState and findPreviewUrlFromPrComments, already walk this identical endpoint via findAcrossPages. The file's own header comment reasons about exactly this: a commit with >100 check-runs pushes the Cloudflare Workers Builds check-run onto page 2+, and a page-1-only read then returns null as if the preview didn't exist — so the PR comment shows a permanent loading spinner even though the deploy succeeded (getPreviewBuildState, which paginates, reports succeeded).

Fix

Route the check-runs fetch through findAcrossPages, reusing the exact pattern getPreviewBuildState already applies to this endpoint — no new pagination loop. The per-run preview-URL scan moves into the page probe unchanged.

Tests (preview-url.test.ts had no findPreviewUrlFromChecks coverage before)

  • a preview check-run on page 2 is still found (asserts the walk reached page 2 — verified this fails against the old page-1-only code)
  • a page-1 hit takes no extra request
  • a failed check-run is skipped, the real preview still wins
  • an always-Link: next / no-check_runs response terminates bounded at null

Changed lines are 100% covered (statements + branches); root typecheck clean; src/review/** diff only (2 files).

Closes #7779

findPreviewUrlFromChecks fetched only page 1 of a head SHA's check-runs
(?per_page=100) and never followed pagination, while its two siblings in the
same file -- getPreviewBuildState and findPreviewUrlFromPrComments -- already
walk this identical endpoint via findAcrossPages. The file's own header comment
reasons about exactly this failure: a commit with >100 check-runs pushes the
Cloudflare Workers Builds check-run onto page 2+, and a page-1-only read then
returns null as if the preview didn't exist -- so the PR comment shows a
permanent loading spinner even though the deploy succeeded.

Route the check-runs fetch through findAcrossPages, reusing the exact pattern
getPreviewBuildState already applies to this endpoint (no new pagination loop);
the per-run preview-URL scan moves into the page probe unchanged.

Adds regression tests: a preview check-run on page 2 is still found (asserting
the walk reaches page 2), a page-1 hit takes no extra request, a failed
check-run is skipped, and an all-next-Link/no-check_runs response terminates
bounded at null.

Closes JSONbored#7779
@davion-knight
davion-knight requested a review from JSONbored as a code owner July 21, 2026 15:54
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.77%. Comparing base (283fb8f) to head (654d65a).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7881      +/-   ##
==========================================
- Coverage   91.40%   88.77%   -2.63%     
==========================================
  Files         730       89     -641     
  Lines       74763    21353   -53410     
  Branches    22815     3722   -19093     
==========================================
- Hits        68335    18957   -49378     
+ Misses       5385     2213    -3172     
+ Partials     1043      183     -860     
Flag Coverage Δ
shard-1 ?
shard-2 2.15% <0.00%> (-49.69%) ⬇️
shard-3 77.69% <100.00%> (+27.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/review/visual/preview-url.ts 77.69% <100.00%> (-6.98%) ⬇️

... and 641 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-21 16:05:47 UTC

2 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This is a focused, correct fix that routes findPreviewUrlFromChecks through the same findAcrossPages helper its two siblings (getPreviewBuildState, findPreviewUrlFromPrComments) already use, closing the exact gap #7779 describes: a >100-check-run head SHA could push the Cloudflare preview check-run past page 1 and return a false null. The implementation is a straightforward call-site swap (githubJson -> findAcrossPages) with the same skip-failed/extract-url probe logic preserved unchanged, and the new tests directly exercise page-2 discovery, the no-extra-request page-1 case, the failed-run-skip case, and a bounded-termination case with no check_runs field — all plausible real paths, not fabricated ones. The PR is narrow (one file + its test), closes a linked issue, and CI is fully green.

Nits — 4 non-blocking
  • src/review/visual/preview-url.ts: the new comment atop the findAcrossPages call is fairly long relative to the small code change; could be trimmed since the file header already explains the pagination rationale in detail.
  • test/unit/preview-url.test.ts: the 'bounded walk' test relies on an always-next Link header and PREVIEW_LIST_MAX_PAGES (10 iterations) to terminate — worth a comment noting it implicitly asserts termination within that bound rather than hanging, since the assertion itself only checks the resolved value.
  • Consider asserting call count in the bounded-walk test (expect fetchMock to have been called exactly 10 times) to make the boundedness explicit rather than implicit.
  • No functional changes needed; this mirrors the existing getPreviewBuildState pattern well.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7779
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 147 registered-repo PR(s), 92 merged, 4 issue(s).
Contributor context ✅ Confirmed Gittensor contributor davion-knight; Gittensor profile; 147 PR(s), 4 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff replaces the raw githubJson page-1-only fetch in findPreviewUrlFromChecks with a call to the existing findAcrossPages helper, mirroring the pattern used by getPreviewBuildState/findPreviewUrlFromPrComments, and adds regression tests confirming a page-2 check-run is now found. This directly satisfies the issue's required pattern and includes the requested >100 check-runs / page-2 regressio

Review context
  • Author: davion-knight
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Rust
  • Official Gittensor activity: 147 PR(s), 4 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit e84b4e1 into JSONbored:main Jul 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

findPreviewUrlFromChecks doesn't paginate check-runs, unlike its sibling functions in the same file

2 participants