fix: fall back to compatible initia binary release#208
Conversation
## Summary - fix `weave init` failing when the chain-reported Initia version has no matching GitHub release asset - prefer the exact release tag when available - fall back to the highest downloadable release in the same major.minor series ## Testing - `go test ./cosmosutils` - built local binary and verified `weave init` passes the previous failure point
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughQueries initia-labs/initia GitHub releases to select a platform-compatible release (exact tag or highest patch within the same major.minor), finds the platform Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Module as cosmosutils/binary.go
participant GitHub as GitHub Releases API
participant Platform as Local OS/ARCH
Caller->>Module: Request initia binary URL for version X
Module->>Platform: determine GOOS/GOARCH
Module->>GitHub: list releases (per_page=100) for initia-labs/initia
GitHub-->>Module: releases (tags + assets)
Module->>Module: normalize & validate semver tags
Module->>Module: select exact-tag or highest patch in same major.minor
Module->>Module: locate GOOS_GOARCH.tar.gz asset URL
alt compatible release found
Module-->>Caller: return selected tag + asset URL
else none found
Module-->>Caller: return error ("no compatible downloadable release")
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cosmosutils/binary_test.go (1)
231-302: Consider adding edge case tests for robustness.The test covers the main scenarios well, but a few edge cases are missing:
- Empty releases list – implementation handles this at line 263-265
- Invalid target version format – implementation validates at line 268-270
- Exact tag exists but lacks platform asset – should fallback rather than fail
These aren't blockers but would strengthen confidence in the fallback logic.
💡 Additional test case suggestion
{ name: "exact tag exists but lacks platform asset, falls back", targetVersion: "v1.4.1", releases: []BinaryRelease{ { TagName: "v1.4.1", Assets: []struct { BrowserDownloadURL string `json:"browser_download_url"` }{ {BrowserDownloadURL: "example.com/initia_v1.4.1_Windows_x86_64.tar.gz"}, // incompatible platform }, }, { TagName: "v1.4.0", Assets: []struct { BrowserDownloadURL string `json:"browser_download_url"` }{ {BrowserDownloadURL: assetURL("v1.4.0")}, }, }, }, expectedTag: "v1.4.0", expectedURL: assetURL("v1.4.0"), }, { name: "empty releases list", targetVersion: "v1.0.0", releases: []BinaryRelease{}, expectedErrStr: "no releases found", },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cosmosutils/binary_test.go` around lines 231 - 302, Add three edge-case entries to the existing tests table to improve coverage: (1) an "empty releases list" case with targetVersion "v1.0.0", releases set to []BinaryRelease{} and expectedErrStr "no releases found"; (2) an "invalid target version format" case with a malformed targetVersion (e.g. "1.0") and the appropriate expectedErrStr matching the validation error the code emits; and (3) an "exact tag exists but lacks platform asset, falls back" case where a release with TagName "v1.4.1" has an incompatible BrowserDownloadURL and a lower compatible release "v1.4.0" exists—set expectedTag to "v1.4.0" and expectedURL to assetURL("v1.4.0"). Reference the tests table, BinaryRelease struct and assetURL helper when adding these entries so they integrate with the existing test loop.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cosmosutils/binary_test.go`:
- Around line 231-302: Add three edge-case entries to the existing tests table
to improve coverage: (1) an "empty releases list" case with targetVersion
"v1.0.0", releases set to []BinaryRelease{} and expectedErrStr "no releases
found"; (2) an "invalid target version format" case with a malformed
targetVersion (e.g. "1.0") and the appropriate expectedErrStr matching the
validation error the code emits; and (3) an "exact tag exists but lacks platform
asset, falls back" case where a release with TagName "v1.4.1" has an
incompatible BrowserDownloadURL and a lower compatible release "v1.4.0"
exists—set expectedTag to "v1.4.0" and expectedURL to assetURL("v1.4.0").
Reference the tests table, BinaryRelease struct and assetURL helper when adding
these entries so they integrate with the existing test loop.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d5bb276e-6077-4e00-a911-a163463a5f28
📒 Files selected for processing (2)
cosmosutils/binary.gocosmosutils/binary_test.go
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cosmosutils/binary.go`:
- Around line 593-603: The release lookup currently calls fetchReleases with the
GitHub releases URL without pagination, which will miss releases after the
default page size; update the call that passes the URL (the string literal in
the call to fetchReleases in the function around
selectCompatibleReleaseForVersion) to include ?per_page=100 (i.e.,
"https://api.github.com/repos/initia-labs/initia/releases?per_page=100") so up
to 100 releases are returned, or alternatively implement proper pagination
inside fetchReleases if you expect >100 releases.
In `@Makefile`:
- Line 9: The fallback WEAVE_VERSION value can be non-semver (commit SHA or
"dev") which breaks CompareSemVer by padding non-numeric segments with
MaxIntPadding and treating them as lowest versions; either: change the Makefile
WEAVE_VERSION fallback to a semver-compatible sentinel like "v0.0.0-dev" so
strconv.Atoi and semver parsing behave (update the WEAVE_VERSION assignment), or
add validation in the comparison path (CompareSemVer / Version parsing logic) to
detect non-semver strings and return a clear error/skip comparison (do not
pad/compare using MaxIntPadding) so weave upgrade rejects or handles non-semver
current versions safely. Ensure references to MaxIntPadding, strconv.Atoi,
CompareSemVer, and any Version struct are updated accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6c977b82-51e4-4fb7-be8c-55d1002205b2
📒 Files selected for processing (2)
Makefilecosmosutils/binary.go
Summary
weave initfailing when the chain-reported Initia version has no matching GitHub release assetTesting
go test ./cosmosutilsweave initpasses the previous failure pointSummary by CodeRabbit
New Features
Tests
Chores