Skip to content

fix(selfupdate): list all release pages so latest stable is found#520

Merged
skevetter merged 2 commits into
mainfrom
fix/selfupdate-latest-stable-pagination
Jun 23, 2026
Merged

fix(selfupdate): list all release pages so latest stable is found#520
skevetter merged 2 commits into
mainfrom
fix/selfupdate-latest-stable-pagination

Conversation

@skevetter

@skevetter skevetter commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Problem

self update fails with no release found, and the self-update e2e spec (self update --dry-run) fails in CI — independent of this being a network/token issue.

Root cause is release pagination, not rate limiting:

  • go-selfupdate's GitHub source lists only the first page (30 releases) via ListReleases(..., nil).
  • devsy-org/devsy currently has 31 pre-releases (v1.10.0-beta.*) ahead of the latest stable v1.9.8 (index 31 → page 2).
  • On the stable channel, DetectLatest/DetectVersion filter page 1, find no non-prerelease, and return found=falseno release found → exit 1.

It looked "flaky" but is actually deterministic and time-dependent: it breaks once ≥30 pre-releases accumulate after the last stable, and will recur whenever that happens.

Fix

Inject a custom selfupdate.Source (allPagesSource) that pages through all releases using go-github, and pass it via selfupdate.Config{Source: ...}. It embeds the stock GitHubSource, so asset download/decompress/replace is unchanged — only release listing is overridden. Honors GITHUB_TOKEN when present (same as the library).

This fixes both channels:

  • stable — latest non-prerelease is found even behind many betas
  • beta — unchanged (prereleases are on page 1 anyway)

Changes

  • pkg/selfupdate/source.goallPagesSource paginating Source + newAllPagesSource
  • pkg/selfupdate/selfupdate.go — wire the source into detectRelease
  • pkg/selfupdate/source_test.go — httptest-backed test verifying pagination follows NextPage and a release on page 2 is returned
  • go.mod — promotes google/go-github/v74 from indirect to direct (same version)

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed self-update feature to properly retrieve all available GitHub releases across paginated results instead of only the first page
  • Tests

    • Added unit test to verify pagination is correctly handled and releases from all pages are aggregated properly
  • Chores

    • Updated dependency management

`self update` (and its e2e dry-run test) failed with "no release found"
once more than ~30 pre-releases had shipped since the last stable
release. go-selfupdate's default GitHub source lists only the first page
(30 releases), so the latest stable fell onto page 2 and was never seen
by DetectLatest/DetectVersion.

Inject a custom Source that pages through all releases via go-github,
embedding the stock GitHubSource so asset downloads are unchanged. Fixes
both stable and beta channels regardless of how many pre-releases
precede the target.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 3d6befa
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a3aa4bbd85e230008b81c43

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 74645590-080d-415f-92bd-a09b39339613

📥 Commits

Reviewing files that changed from the base of the PR and between 69e29e5 and 3d6befa.

📒 Files selected for processing (4)
  • go.mod
  • pkg/selfupdate/selfupdate.go
  • pkg/selfupdate/source.go
  • pkg/selfupdate/source_test.go

📝 Walkthrough

Walkthrough

A new allPagesSource type is added to pkg/selfupdate/source.go that fetches GitHub releases across all pagination pages using a go-github client with optional token auth. It is wired into detectRelease in selfupdate.go. The go-github v74 dependency is reclassified from indirect to direct in go.mod.

Changes

Paginated Release Source

Layer / File(s) Summary
allPagesSource implementation and test
pkg/selfupdate/source.go, pkg/selfupdate/source_test.go, go.mod
Introduces the unexported allPagesSource struct and newAllPagesSource() constructor that builds a go-github client with optional GITHUB_TOKEN auth. ListReleases iterates pages using PerPage=100 and resp.NextPage, accumulating all releases into one slice with errors wrapped as list releases for owner/repo. The test asserts pagination-follow and result aggregation via an httptest server emitting Link: rel=next headers. go.mod promotes github.com/google/go-github/v74 from indirect to direct.
Wire source into detectRelease
pkg/selfupdate/selfupdate.go
detectRelease now calls newAllPagesSource(), returns a wrapped error on failure, and passes the source into selfupdate.NewUpdater via the Source config field.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: implementing pagination to list all release pages to ensure the latest stable version is found, directly addressing the root cause of the bug.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 1b95c0f
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a39cf83d004400008214024

@netlify

netlify Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 3d6befa
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a3aa4bbd6d7520008fbfb6d

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@skevetter
skevetter marked this pull request as ready for review June 23, 2026 16:21
@skevetter
skevetter merged commit 51c028f into main Jun 23, 2026
102 of 104 checks passed
@skevetter
skevetter deleted the fix/selfupdate-latest-stable-pagination branch June 23, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant