Skip to content

fix(otto): pin auto-update download to cached version - #2135

Open
jlaneve wants to merge 1 commit into
mainfrom
otto-autoupdate-version-pin
Open

fix(otto): pin auto-update download to cached version#2135
jlaneve wants to merge 1 commit into
mainfrom
otto-autoupdate-version-pin

Conversation

@jlaneve

@jlaneve jlaneve commented May 18, 2026

Copy link
Copy Markdown
Contributor

Summary

User feedback: astro otto printed

Updating Otto 0.1.7 → 0.1.8...
Otto 0.1.10 installed

autoUpdate logged state.LatestKnown from the cached .update-check file, but downloadAndInstall always fetched the CDN's /latest/ alias. When a release shipped between cache refreshes, the two paths diverged.

Changes

  • downloadURL(version) and downloadAndInstall(version) now take a version string. The CDN already hosts versioned paths (/vX.Y.Z/...), so autoUpdate passes state.LatestKnown and the download URL matches the log line.
  • EnsureBinary and Update() keep using "latest" via a new sentinel const.
  • v-prefix add is idempotent (!strings.HasPrefix(v, "v")) so callers can pass either form.

Test plan

  • go build ./pkg/otto/...
  • go vet ./pkg/otto/...
  • go test ./pkg/otto/...
  • New regression test TestAutoUpdate_PinsDownloadToCachedVersion fails on the old downloader signature
  • New TestDownloadURL_PinnedVersion + _AlreadyPrefixed cover both v-prefix forms

autoUpdate logged "Updating Otto X → Y" using the cached LatestKnown
value but downloaded from /latest/ on the CDN. When a release shipped
between cache refreshes the two diverged, so users saw lines like
"Updating Otto 0.1.7 → 0.1.8... Otto 0.1.10 installed".

Thread the cached version through downloadAndInstall and downloadURL so
the download path matches the version the log promised. EnsureBinary and
Update keep using "latest" via a new sentinel const.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jlaneve
jlaneve requested a review from a team as a code owner May 18, 2026 17:39
@coveralls-official

Copy link
Copy Markdown

Coverage Report for CI Build 25

Coverage increased (+0.003%) to 39.769%

Details

  • Coverage increased (+0.003%) from the base build.
  • Patch coverage: 7 uncovered changes across 1 file (8 of 15 lines covered, 53.33%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
pkg/otto/binary.go 13 6 46.15%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 65900
Covered Lines: 26208
Line Coverage: 39.77%
Coverage Strength: 9.4 hits per line

💛 - Coveralls

@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 60 days with no activity.

@github-actions github-actions Bot added the stale label Jul 18, 2026
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