fix(upgrade): detect same-version re-cut releases via checksum staleness#9
Merged
Conversation
Date tags (vYYYY.MM.DD) get re-cut under the same tag when we ship more than once a day, so an equal tag can point at a different published binary. `orva upgrade` compared only the semver tag, so a user who upgraded earlier the same day was wrongly told "already the latest" after a re-cut. When the latest tag isn't strictly newer, also compare the running binary's SHA-256 against the published checksum for its platform asset (latest.AssetName in latest.ValidationAssetURL) and reinstall on a mismatch. Self-contained: the slim CLI can't import backend/internal/version (no commit to compare), and the release already publishes checksums.txt. - upgradeAction: pure install decision (force | versionNewer | rebuilt). - remoteBuildDiffers: best-effort checksum probe; returns known=false on any network/parse failure so it falls back to version-only (10s bounded fetch, never hangs/blocks the upgrade). - fileSHA256 / remoteAssetSHA / parseChecksums helpers. - --check now reports "newer build available (same version, rebuilt)". - upgrade_test.go: decision truth table, hasher, checksums parsing (two-space and *name forms), and remoteBuildDiffers over httptest (equal/differ/absent/ no-validation-url). Verified live: a binary stamped v2026.06.04 but built locally (different bytes) correctly reports a rebuilt build is available; older tags still upgrade by version; an unreachable repo fails gracefully without hanging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
orva upgradewas blind to same-day re-cut releases. Date tags (vYYYY.MM.DD) are re-cut under the same tag when we ship more than once a day, but the upgrader compared only the semver tag — so a user who upgraded earlier the same day was told "already the latest" after a re-cut, even though the published binary changed.Fix: when the latest tag isn't strictly newer, also compare the running binary's SHA-256 against the published checksum for its platform asset (
latest.AssetNamelooked up inlatest.ValidationAssetURL— both already returned by go-selfupdate). A mismatch ⇒ a fresh build under the same tag ⇒ reinstall.upgradeAction— pure decision (force | versionNewer | rebuilt).remoteBuildDiffers— best-effort checksum probe;known=falseon any network/parse failure ⇒ falls back to version-only (10s bounded fetch, never hangs/blocks the upgrade).fileSHA256/remoteAssetSHA/parseChecksumshelpers.--checknow reportsnewer build available (same version, rebuilt).Self-contained: the slim CLI can't import
backend/internal/version(no commit to compare), and the release already publisheschecksums.txt. No tag-scheme change, no new deps.Validation
go build ./... && go vet ./... && go test -race ./cli/commands/green; newupgrade_test.gocovers the decision truth table, hasher, checksums parsing (two-space +*name), andremoteBuildDiffersover httptest (equal / differ / absent / no-validation-url).v2026.06.04but built locally (different bytes) →upgrade --checkcorrectly reports "newer build available (same version, rebuilt)"; an older tag still upgrades by version; an unreachable repo fails gracefully without hanging.Notes
orva upgradeon the full server binary sees a mismatch vs the CLI asset and offers to replace it — same direction as a version bump;orva upgradeis the CLI self-update path (servers update via install.sh/Docker).cli/commands/upgrade.go+ tests +cli/CLAUDE.md.