Skip to content

fix(review): paginate getLatestDeploymentStatus's deployments and statuses reads - #7829

Closed
shin-core wants to merge 1 commit into
JSONbored:mainfrom
shin-core:fix/paginate-deployment-status-7805
Closed

fix(review): paginate getLatestDeploymentStatus's deployments and statuses reads#7829
shin-core wants to merge 1 commit into
JSONbored:mainfrom
shin-core:fix/paginate-deployment-status-7805

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What

getLatestDeploymentStatus (src/review/visual/preview-url.ts) fetched only page 1 of a head SHA/ref's Deployments list (?...&per_page=10) and page 1 of each deployment's statuses — never following GitHub's Link: rel="next", unlike this same file's findPreviewUrlFromPrComments and getPreviewBuildState. A ref with more than 10 deployment records (repeated CI re-runs, multiple environments per push, a long-lived branch) can carry the deployment with the real environment_url outside page 1, so the function returned { url: null } as if no preview existed — the same false-negative class the file's own header warns about, and the class #7469 already fixed for the comment/check-run reads (#7805 is the third, still-unpaginated instance).

Fix

Reuse the existing findAcrossPages helper (same file) for both reads, exactly the way the two sibling functions already do:

  • Walk every page of the deployments list; on each page, scan each deployment's statuses and return the first usable environment_url.
  • Walk every page of a deployment's statuses when scanning for a success/in_progress status with an environment_url.

findAcrossPages now awaits its probe so the outer deployments scan can fetch each deployment's statuses per page (a synchronous probe — the two existing callers — is unaffected, since await on a non-promise is a no-op). The sawFailure/sawPending bookkeeping and the DeploymentLookup return contract are preserved exactly; the failed/pending verdict keys off each deployment's statuses[0] "latest" status as before, and now accumulates across all deployments/pages.

Tests

test/unit/preview-url.test.ts, mirroring the file's existing NEXT_LINK/isPage2 page-2 tests:

  • A deployment whose environment_url sits on page 2 of the deployments list — the URL is still found.
  • A usable success status on page 2 of a deployment's statuses — the URL is still found.

Both are proven to fail when pagination is capped to page 1.

Validation

  • npx vitest run test/unit/preview-url.test.ts — 25/25; broad findAcrossPages-consumer sweep (preview-url + visual-capture) — 321/321 (the async-probe widening breaks no existing caller). npm run typecheck — exit 0. git diff --check clean.

Closes #7805

@shin-core
shin-core requested a review from JSONbored as a code owner July 21, 2026 14:06
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 21, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@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.82%. Comparing base (9d95c96) to head (48e1c9e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7829      +/-   ##
==========================================
+ Coverage   80.62%   88.82%   +8.19%     
==========================================
  Files         729       89     -640     
  Lines       74671    21351   -53320     
  Branches    22791     3722   -19069     
==========================================
- Hits        60205    18964   -41241     
+ Misses      11654     2196    -9458     
+ Partials     2812      191    -2621     
Flag Coverage Δ
shard-1 44.52% <30.43%> (-9.98%) ⬇️
shard-2 2.18% <0.00%> (-53.00%) ⬇️
shard-3 76.64% <100.00%> (?)

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 83.94% <100.00%> (+22.10%) ⬆️

... and 640 files with indirect coverage changes

…tuses reads

getLatestDeploymentStatus fetched only page 1 of a head SHA/ref's Deployments
list (per_page=10) and page 1 of each deployment's statuses -- never following
GitHub's Link: rel="next", unlike this file's own findPreviewUrlFromPrComments
and getPreviewBuildState. A ref with more than 10 deployments (repeated CI
re-runs, multiple environments, a long-lived branch) could carry the deployment
with the real environment_url outside page 1, so the function under-reported a
missing preview exactly as if none existed -- the same false-negative class the
file's own header warns about, and the class JSONbored#7469 already fixed for the
comment/check-run reads.

Reuse the existing findAcrossPages helper for both reads, the way the sibling
functions do: walk deployment pages, and per deployment walk its status pages,
returning the first usable environment_url. findAcrossPages now awaits its probe
so the outer deployments scan can fetch each deployment's statuses (a sync probe
is unaffected). The sawFailure/sawPending bookkeeping and DeploymentLookup return
contract are preserved.

Closes JSONbored#7805
@shin-core
shin-core force-pushed the fix/paginate-deployment-status-7805 branch from 94006b8 to 48e1c9e Compare July 21, 2026 14:27
@loopover-orb loopover-orb Bot closed this Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

This repository reviews pull requests one-shot: the PR must be correct as originally opened. Pushing an additional commit closes it automatically instead of restarting review — open a fresh pull request with every fix included.

@loopover-orb loopover-orb Bot added review-evasion Gittensor contributor context gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. labels Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. review-evasion Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getLatestDeploymentStatus doesn't paginate deployments/statuses reads, unlike its siblings in the same file

1 participant