Skip to content

fix: fall back to compatible initia binary release#208

Merged
Benzbeeb merged 4 commits intomainfrom
fix/initia-binary-version-fallback
Apr 2, 2026
Merged

fix: fall back to compatible initia binary release#208
Benzbeeb merged 4 commits intomainfrom
fix/initia-binary-version-fallback

Conversation

@restorenode
Copy link
Copy Markdown
Collaborator

@restorenode restorenode commented Apr 2, 2026

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

Summary by CodeRabbit

  • New Features

    • Dynamic binary selection: prefers exact version matches and falls back to the highest compatible patch within the same minor series, with platform/architecture asset detection and explicit error when no downloadable release is found.
  • Tests

    • Added tests covering exact-match, patch-fallback, and no-compatible-release scenarios.
  • Chores

    • Build version now falls back to a default dev value when tag lookup fails.

## 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
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 92bbc7f1-0e44-4ddc-ac01-e015c7569a57

📥 Commits

Reviewing files that changed from the base of the PR and between 5abf0d4 and e6fa251.

📒 Files selected for processing (1)
  • cosmosutils/binary.go

Walkthrough

Queries initia-labs/initia GitHub releases to select a platform-compatible release (exact tag or highest patch within the same major.minor), finds the platform GOOS_GOARCH.tar.gz asset URL, and returns the matched tag and URL. The Makefile WEAVE_VERSION now falls back to v0.0.0-dev if git describe fails.

Changes

Cohort / File(s) Summary
Release-Selection Logic
cosmosutils/binary.go
Adds helpers getPlatformAssetURL, majorMinorVersion, and selectCompatibleReleaseForVersion; changes GetInitiaBinaryUrlFromLcd to list GitHub releases (per_page=100), validate/normalize semver, and select an exact or highest patch release that contains a GOOS_GOARCH.tar.gz asset, returning tag + asset URL and explicit errors when not found.
Release-Selection Tests
cosmosutils/binary_test.go
Adds TestSelectCompatibleReleaseForVersion validating exact-tag selection, fallback to highest patch within same minor series, and error case when no downloadable compatible release exists; uses getOSArch to build expected asset URLs.
Build Metadata Fallback
Makefile
WEAVE_VERSION now silences git describe stderr and falls back to v0.0.0-dev when git describe --tags fails; value still injected into LDFLAGS.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through tags both big and small,
sniffed assets for my OS and all,
found the patch that fit just right,
fetched the tarball — what a delight!
🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: fall back to compatible initia binary release' directly and clearly summarizes the main change: implementing a fallback mechanism to select compatible Initia binary releases when exact matches aren't available.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/initia-binary-version-fallback

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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:

  1. Empty releases list – implementation handles this at line 263-265
  2. Invalid target version format – implementation validates at line 268-270
  3. 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

📥 Commits

Reviewing files that changed from the base of the PR and between fd33c05 and f95ac4c.

📒 Files selected for processing (2)
  • cosmosutils/binary.go
  • cosmosutils/binary_test.go

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 2, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between f95ac4c and 6d1519a.

📒 Files selected for processing (2)
  • Makefile
  • cosmosutils/binary.go

Comment thread cosmosutils/binary.go
Comment thread Makefile Outdated
Benzbeeb
Benzbeeb previously approved these changes Apr 2, 2026
@restorenode restorenode requested a review from Benzbeeb April 2, 2026 05:06
@Benzbeeb Benzbeeb merged commit 2ca415c into main Apr 2, 2026
8 checks passed
@Benzbeeb Benzbeeb deleted the fix/initia-binary-version-fallback branch April 2, 2026 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants