Repository navigation
cmd: cross-check update checksums with the GitHub release (PRINFRA-6744) - #584
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Approve at a716482c.
What I checked in update_cdn.go:
UpdateToreads the CDNchecksums.txtonce. It takeswantfrom those bytes, requiresbytes.Equalagainst the GitHub release's copy, and only then downloads and hashes the CDN archive againstwant. The bytes compared are the bytes used, so there is no second fetch to race. When the GitHub copy is missing or unreadable, the update stops before any download.- GitHub client: the start URL is a constant (not affected by
HEYGEN_CDN_BASE_URL). Redirects are capped at 3 hops and must stay onrelease-assets.githubusercontent.com/objects.githubusercontent.com. The CDN client still refuses every redirect. DetectLatest,--checkand the notice now resolve the same way: pointer, then this platform's entry in that release's CDNchecksums.txt. A 403/404 on that file, or no entry for this platform, means "no update". Any other status surfaces as an error.fetchStablePointerno longer turns a refused pointer into "not found"; onlyexpectedChecksummaps 403/404 toerrReleaseNotFound.- The rollback-failure message wraps the original error and names the reinstall command.
Tests on Go 1.26: the update tests pass. I broke each check on purpose:
| Mutation | Result |
|---|---|
skip the bytes.Equal cross-check |
caught (GitHub_release_lists_different_checksums) |
| allow any redirect host | caught |
DetectLatest ignores the platform entry |
caught (release_lacks_this_platform) |
notice back to fetchStablePointer |
caught |
403 no longer means missing / objectMissing off |
caught (missing_version_answers_403) |
entry match via strings.Contains (survived on #583) |
now caught (StableInstallsVerifiedArchiveFromCDN, lookalike line) |
drop the https scheme check in githubAssetRedirect |
survives |
| ignore the GitHub fetch error | survives, harmlessly: nil never equals a real file, so the update still refuses with a less precise message |
Notes, none blocking:
- The "immutable" premise is not true for this repo yet. The comment on
updateGitHubReleaseURLsays published releases are immutable, but the releases API reports"immutable": falsefor v0.8.1, v0.9.0, v0.10.0 and v0.11.0. The cross-check still means someone has to tamper with both stores to ship a bad binary, which is the real win. But today a token that can edit releases can rewrite an existing version's GitHubchecksums.txtafter it ships. Turning on immutable releases in the repo settings would make the comment true. Otherwise, reword the comment. - The scheme check has no test. The fakes are plain-HTTP servers, so nothing exercises
u.Scheme == "https". Exposure is small, because the redirected bytes still have to match the CDN copy exactly. A unit test ofgithubAssetRedirectwithhttp://release-assets.githubusercontent.com/...would pin it. - New behavior: stable updates now need github.com as well as static.heygen.ai. A network that blocks github.com but allows the CDN can still run
install.sh, butheygen updatewill now fail there. That trade-off is probably right; a sentence in RELEASE.md would save a support question. - Unrelated, so you know it's not from this PR: a full
go test ./cmd/heygen/on a loaded box failedTestGenBuilder_*_Wait_Timeout_*twice, a different case each time. Those are timing-sensitive tests unrelated to this diff.
— Rames
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
a716482 to
63eb240
Compare
jrusso1020
left a comment
There was a problem hiding this comment.
Re-review at 63eb240. Approving.
- The rebase onto #582 is clean.
git range-diffshows the cross-check commit unchanged (a716482 = 9f1753a). - The new comment is accurate.
GET /repos/heygen-com/heygen-cli/immutable-releasesreturnsenabled: true, and v0.7.0 through v0.11.0 all reportimmutable: false. So the protection that holds today is the two-source match, which is what the comment now says. - The new
TestGitHubAssetRedirectcatches both mutations I tried. Dropping the https check fails it on thehttp://case, and replacing the exact host match with a prefix match fails it on the.example.comlookalike. - The RELEASE.md network note is accurate:
scripts/install.shnever references github.com.
Go 1.26.11: the update tests pass, and go vet and gofmt are clean.
Review by Rames
…not no update Co-Authored-By: Claude Opus 5.5 <[email protected]>
jrusso1020
left a comment
There was a problem hiding this comment.
Re-review at e8e39ae, which is one new commit on top of 63eb240. Approving.
Error mapping. It reads correctly.
expectedChecksumnow returns a failed read unchanged and wraps only the "no entry for this platform" case.DetectLatesttreats only that case as "no update".DetectVersionstill treats 403/404 as not found, throughobjectMissing.- No references to the old
errReleaseNotFoundremain. - The notice worker still swallows the failure, so users see no notice rather than an error. It returns before
writeUpdateCache, so the next check runs again. release-stable.ymluploadsreleases/<tag>/, includingchecksums.txt, before it flipsstable. So a normal publish never makes this new error visible.
Mutations, both caught:
- Putting
objectMissingback intoDetectLatestfailsTestUpdateCheck_UnreadableChecksumsForLatestIsAnError. - Dropping it from
DetectVersionfailsTestUpdate_VersionResolvesItsCDNFolder.
withRollbackHint. It is correct, and it is defensive today. In go-selfupdate v1.5.0, Updater.UpdateTo returns update.Apply's error unwrapped, through decompressAndUpdate. So the outer layer already matches on both paths, and RollbackError really does only type-assert (err.(*rollbackError)). The errors.Unwrap loop is harmless.
Non-blocking nits:
- Nothing tests the hint. Changing the loop to check only the outer layer passes the suite. A small fake error that wraps an
update.Applyrollback failure would pin it. - On the dev updater the hint suggests
install.sh, which installs the latest stable. That is still a sensible recovery for a missing binary, but it moves a dev-channel user onto stable. Consider wording it that way.
Go 1.26.11: the full cmd/heygen package passes.
Review by Rames
Scope
Surfaces: CLI | Module: Self-update
Summary
Follow-ups to the CDN self-update in #583. A stable update now installs only when the CDN's
checksums.txtmatches the one on the GitHub release, andupdate --checkand the update notice offer only releases built for this platform. Live on the next release.How it works
checksums.txtfrom the GitHub release for the same version. The two files must be identical. If they differ, or either is missing, the update stops and the installed binary stays as it was.update --check,updateand the notice report a new release only if itschecksums.txtlists an archive for this platform. Otherwise they report no update, as the GitHub-based updater did.--versionlookups call a 403/404 "not found".--versionrule and the cross-check.Testing
checksums.txt, a redirect off GitHub's asset host, a lookalike file name listed before the real entry, a release without this platform (--checkand notice agree), a refused stable pointer, and aHEYGEN_CDN_BASE_URLvalue having no effect.v0.10.0build tov0.11.0against the real CDN and GitHub.checksums.txtare byte-identical for existing releases.Closes PRINFRA-6744.
🤖 Generated with Claude Code