Skip to content

fix(cube-cli): Install the newest release that ships this platform's binary - #12435

Merged
paveltiunov merged 7 commits into
masterfrom
pavel-claude/optimistic-cannon-dgpym6
Oct 27, 2026
Merged

paveltiunov merged 7 commits into
masterfrom
pavel-claude/optimistic-cannon-dgpym6

Conversation

@paveltiunov

@paveltiunov paveltiunov commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Check List

  • Tests have been run in packages where changes have been made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Issue Reference this PR resolves

CORE-694. Replaces #11426.

Description of Changes Made

v1.7.14 shipped without cube-aarch64-apple-darwin.tar.gz, so install-cli.sh 404'd on every Apple Silicon Mac. The installers download from releases/latest/download/…, and cube update and the background update check read /releases/latest. All of them looked only at the single latest release. When that release lacks this platform's binary, they fail. That happens after a failed upload, and also briefly during every release: binaries are uploaded after the release is published.

Now install-cli.sh, install-cli.ps1 and the CLI (update::latest_release) list recent releases. Each picks the highest stable version that lists this platform's asset:

  • Drafts and prereleases are skipped. In the CLI, assets that are still uploading (state != "uploaded") are skipped too.
  • The pick is by version, not by list position. Maintenance releases such as v1.6.75 are published between v1.8.x releases.
  • If a download fails, the installers try up to 3 candidates. If the API is unreachable or rate limited, they fall back to releases/latest.
  • GITHUB_TOKEN, when set, is sent only to api.github.com. It never goes to a CUBE_RELEASES_URL mirror or to download URLs.
  • CUBE_VERSION pinning is unchanged.
  • Response size: the list of 30 releases is about 2 MB raw. It is now requested gzip-compressed, which brings it to about 160 KB: curl --compressed in the installer, and reqwest's gzip feature in the CLI. The per-command background check reads only 10 releases (about 54 KB).
  • cube update and the background check now share one version comparison.
  • Docs: reference/cli.mdx describes how a release is picked, plus CUBE_RELEASES_URL and GITHUB_TOKEN.

Tests

  • rust/cube-cli/tests/installers.sh runs both installers against a local fake of the releases API. The fake has:

    • a higher-versioned draft;
    • a newest release with no CLI assets;
    • a maintenance release published later;
    • a prerelease;
    • a release whose download 404s.

    The test checks that each installer installs the right release. It fails on master (installs the real latest) and passes here. It runs in a new installers job in Cube CLI CI on Ubuntu and macOS, and both images have pwsh, so the PowerShell installer is covered too.

  • Unit tests for newest_installable cover a missing platform asset, an asset still uploading, a maintenance release published later, prereleases and drafts, and an unsupported platform.

  • Checked by hand: cube update --check and install-cli.sh against the real API both resolve v1.8.13.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TgekqDHTbR46jimJ7dY77N

…binary

The installers downloaded from releases/latest, and `cube update` and the
background update check read /releases/latest. When the latest release is
missing a platform's binary — v1.7.14 shipped without aarch64-apple-darwin
after a failed upload, and every release has a window between publishing and
its uploads finishing — installs and updates on that platform failed.

All three now list recent releases and pick the highest stable version that
lists the platform's asset. Maintenance releases of older lines are interleaved
by publish date, so the pick is by version, not position. The installers try
up to three candidates if a download fails, and fall back to releases/latest
if the API is unreachable.

Adds a regression test that runs install-cli.sh and install-cli.ps1 against a
fake releases API, wired into Cube CLI CI.

CORE-694

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgekqDHTbR46jimJ7dY77N
@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @paveltiunov's task in 2m 3s —— View job


Review: 1 high (missing docs), 1 low, 1 nit. I found no bugs in the fix itself.

Details
  • Gather context
  • Review installers and CLI changes
  • Run tests (not run locally, see below)
  • Review threads
  • Post review

Findings

Severity Where Issue
High install-cli.sh:11 CUBE_RELEASES_URL, GITHUB_TOKEN and the new default when CUBE_VERSION is unset aren't in docs-mintlify/reference/cli.mdx (env table at :962, install paragraph at :32). Adding them, or a top-level author comment explaining why no docs are needed, resolves this.
Low install-cli.sh:102, install-cli.ps1:32 The installers don't skip drafts, but the CLI does. With a push-access GITHUB_TOKEN, a draft can use up one of the 3 download attempts.
Nit rust/cube-cli/src/update.rs:89 (+ install-cli.sh:58, install-cli.ps1:44) These comments are 4–5 lines; one sentence is enough.

Checked and fine

  • release_urls grep/awk: escaped JSON in release bodies (\"tag_name\") can't match, because the pattern needs an unescaped " right after the key. The substr suffix match is off-by-one correct, and sort -t. handles the URL dots that follow the version, since numeric parsing stops at the space.
  • Selection logic: picking by version handles maintenance releases published later. Assets whose state isn't uploaded are skipped in the CLI, and the installers fall through on a failed download. A 30-release window is reasonable.
  • cube update / background check: comparing the newest installable release against CURRENT_VERSION can't downgrade. If the newest installable release is older than the running binary, the CLI reports "up to date".
  • Token handling: GITHUB_TOKEN goes only to the API request, never to the download URLs.

Tests

I couldn't run rust/cube-cli/tests/installers.sh or cargo test locally: this session doesn't allow running commands. When I checked, Cube CLI CI, which includes the new installers job, was still running. The coverage looks good: the fake API has a no-asset newest release, a later-published maintenance release, a prerelease and a download that 404s. The unit tests cover the same cases plus drafts and an asset still uploading.

Review threads

The listing returned 0 prior threads of mine, so there was nothing to resolve or re-affirm. I posted all 3 findings as new threads.

Comment thread install-cli.sh Resolved
Comment thread install-cli.sh Resolved
Comment thread rust/cube-cli/src/update.rs Resolved
@paveltiunov
paveltiunov requested a review from keydunov as a code owner October 27, 2026 03:29
@mintlify

mintlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
cubed3 🟢 Ready View Preview Oct 27, 2026, 3:44 AM

💡 Tip: Enable Automations to automatically generate PRs for you.

@github-actions github-actions Bot added the docs Issues that require a documentation improvement label Oct 27, 2026
Drafts are listed to a GITHUB_TOKEN with push access, and their assets can't
be downloaded anonymously. Also shortens the releases/latest rationale
comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgekqDHTbR46jimJ7dY77N
@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @paveltiunov's task in 2m 1s —— View job


No blocking issues. Findings: 0 high, 1 medium (plausible), 1 low.

Review details
  • Gather context (diff, changed files, PR conversation)
  • Review installers (install-cli.sh, install-cli.ps1)
  • Review CLI (rust/cube-cli/src/update.rs)
  • Review tests / CI / docs
  • Review threads
  • Post review

Findings (inline)

  • medium (plausible) rust/cube-cli/src/update.rs:93: the background update check runs on every command. It now pulls 30 full release objects (changelog bodies and dozens of assets each) where it used to pull one. On slow links that likely means more Unknown outcomes from the 1.5 s grace and much more traffic per command. I had no network access here, so I couldn't measure the size. Suggestion: use a smaller page for spawn_check.
  • low rust/cube-cli/src/update.rs:120: the newest_installable doc comment is 4 lines, over the 3-line limit.

Checked, no issues

  • install-cli.sh
    • The grep -oE pattern skips the escaped JSON quotes inside release body, as the fixture tests.
    • The draft and prerelease handling depends on GitHub's key order, tag_name → draft → prerelease → assets. The real API uses that order.
    • The "/" asset suffix match is exact. sort -t. -kNnr orders 1.8.13 above 1.8.9, and the trailing https://… in field 3 doesn't break -n.
    • It falls back to releases/latest when listing fails or returns nothing. Downloads retry the next candidate, which covers assets that are still uploading even without a state check.
  • install-cli.ps1
    • The assign-then-pipe works around the PS 5.1 array unrolling problem.
    • [version]::TryParse and Sort-Object Version -Descending order versions correctly. Prereleases and drafts are filtered out.
  • CLI
    • newest_installable and asset_for_this_platform share the asset() filter, so with a supported platform the bail in commands/update.rs:40 can only fire on an unsupported platform. The new message fits that case.
  • Security: GITHUB_TOKEN goes only to RELEASES_URL, and both are user-controlled. There is still no checksum verification of the downloaded archive, but that predates this PR.
  • Docs: docs-mintlify/reference/cli.mdx covers how the installer picks a release, CUBE_RELEASES_URL and GITHUB_TOKEN, so the docs requirement is met.
  • Tests:
    • The fixture in installers.sh covers a draft, a release with no CLI assets, a later-published maintenance release, a prerelease and a 404 download.
    • Not covered: the releases/latest fallback path, which hardcodes github.com.
    • I couldn't run installers.sh or cargo test because Bash execution needed approval in this run.

Review threads

The listing returned 0 of my own threads, so there were none to resolve or re-affirm.

Comment thread rust/cube-cli/src/update.rs Resolved
Comment thread rust/cube-cli/src/update.rs Resolved
Listing 30 releases is ~2 MB uncompressed. Enable gzip on the HTTP client
(~160 KB) and have the per-command background check read 10 releases
(~54 KB), keeping 30 for cube update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgekqDHTbR46jimJ7dY77N
@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @paveltiunov's task in 1m 39s —— View job


Looks good to merge: 0 high, 0 medium, 1 low.

Review details
  • Read diff and changed files in context
  • Review threads
  • Post review

Findings

  • Low (simplification): rust/cube-cli/src/commands/update.rs:69 is_newer is a copy of the version_key/newer_than logic that this PR extracted in rust/cube-cli/src/update.rs:135. Two copies can drift apart, and then cube update and the background notice would disagree about whether a release is newer. Posted inline on line 22, since line 69 isn't part of the diff.

Checked, no issue

  • install-cli.sh parsing
    • The grep -oE pattern can't match the escaped \"tag_name\" text in release bodies.
    • draft starts at 1 on each tag_name, so a release missing the field is treated as unstable (the safe default).
    • sort -t. reads only the leading number of field 3, so the dots in URLs don't break the sort.
    • When the release listing fails, $tmp/urls is never created, so the -s check falls back to releases/latest.
  • Assets still uploading: only the CLI checks state. The installers don't, but they already handle this: the download 404s and the loop moves on to the next of the 3 candidates.
  • install-cli.ps1: assigning the result before piping avoids the PowerShell 5.1 problem where the whole array goes down the pipeline as one object. $_ refers to the release again after the nested Where-Object. Drafts and prereleases are filtered, and tags that don't parse are skipped.
  • Rust: newest_installable picks by version and skips drafts, prereleases and assets that aren't uploaded. Tags that aren't versions produce an empty key and sort lowest. The background check reads 10 releases and cube update reads 30, which is fine because the pick is by version. Enabling the gzip feature doesn't affect the binary download: GitHub serves release assets without Content-Encoding, so the .tar.gz bytes still reach extract_binary unchanged.
  • Docs: docs-mintlify/reference/cli.mdx covers the new way a release is picked, CUBE_RELEASES_URL, GITHUB_TOKEN and the new cube update wording.
  • Tests: the fake-API test installers.sh covers drafts, missing assets, a maintenance release published later, prereleases, a download that 404s, and JSON quoted in release notes. The unit tests cover the same cases for the CLI.

Not run

cargo test and rust/cube-cli/tests/installers.sh couldn't run because this job doesn't allow those commands. The findings above come from reading the code.

Review threads

The listing returned 0 of my own unresolved threads (no prior threads), so none were resolved or re-affirmed.

Comment thread rust/cube-cli/src/commands/update.rs Resolved
…and the update check

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgekqDHTbR46jimJ7dY77N
@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @paveltiunov's task in 1m 39s —— View job


One low-severity finding, otherwise ready to merge. The issues from the last round are all fixed.

Review details
  • Gather context (diff, changed files, conversation)
  • Review code, tests, docs, comments
  • Reconcile prior review threads
  • Post findings

Findings

  • Low (security): at install-cli.sh:113, both installers send GITHUB_TOKEN to whatever host CUBE_RELEASES_URL names. The PowerShell installer does the same at install-cli.ps1:28. A CI job that points at a mirror and has the token in its env sends the token to the mirror. The header should go only to https://api.github.com/*. Posted inline.

Checked, no issue

  • Last round's issues: cube update now calls update::newer_than, and the duplicate is_newer is gone. Drafts are filtered in install-cli.sh (draft resets on each tag_name), in install-cli.ps1 (-not $_.draft) and in the CLI. The new fixture adds a higher-versioned draft to the fake API, so the test catches a missing draft filter.
  • Background check size: the gzip feature plus BACKGROUND_RELEASES_TO_SCAN = 10 keeps the background request small. Because the pick is by version, the smaller page is still correct.
  • Shell parsing and fallback: the pattern can't match the escaped JSON in release notes. The sort -t. keys read only the leading numbers, so dots in URLs don't break the sort. Without pipefail, an empty grep doesn't trip set -e. When the release listing fails, the -s check falls back to releases/latest.
  • Docs: docs-mintlify/reference/cli.mdx covers the new way a release is picked, CUBE_RELEASES_URL, GITHUB_TOKEN and the new cube update wording.
  • Comments: all are within 3 lines except the 8-line fixture table in installers.sh. That table describes the fake releases and is needed to understand the test.

Not run

rust/cube-cli/tests/installers.sh and cargo test couldn't run because the job's permissions don't allow those commands. The findings above come from reading the code.

Review threads

The listing returned 0 of my own unresolved threads (no prior threads), so none were resolved or re-affirmed.

Comment thread install-cli.sh Resolved
…lers

A CUBE_RELEASES_URL mirror must not receive a CI job's repo token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TgekqDHTbR46jimJ7dY77N
@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @paveltiunov's task in 1m 59s —— View job


Looks good: 0 high, 0 medium, 1 low

Review details
  • Read diff and changed files
  • Check docs coverage
  • Review threads
  • Post findings

Findings

  • Low (perf): install-cli.sh:118-122: the installer downloads the 30-release API list (about 2 MB) with curl without --compressed. With gzip it would be about 160 KB. Posted inline with a suggestion.

Checked, no issues

  • release_urls awk parser: it relies on GitHub's field order (tag_name, draft and prerelease come before assets). Escaped JSON inside body can't match the key regex, because the closing quote is preceded by \. Sorting by version works with BSD and GNU sort when field 3 has the URL after it.
  • If the release list fails to download or parse, or no release has this platform's asset, both installers fall back to releases/latest. CUBE_VERSION pinning works as before.
  • install-cli.ps1: the result is assigned before piping, so PowerShell 5.1 doesn't pass the whole array as one object. It sorts with [version]::TryParse and filters drafts and prereleases.
  • CLI: newest_installable sorts with the shared version_key/newer_than. Assets that are still uploading are excluded. The cube update error message is now only reachable on unsupported platforms, and its wording fits that. The background check reads per_page=10, and reqwest's gzip feature is enabled.
  • The GITHUB_TOKEN header is sent only to https://api.github.com/*, in both installers.
  • Docs: docs-mintlify/reference/cli.mdx covers how the installer picks a release, CUBE_RELEASES_URL, GITHUB_TOKEN, and the new cube update wording.
  • No new comment is longer than 3 lines, and none just restates the code.
  • I didn't run tests/installers.sh or cargo test because running shell commands needed approval in this job. The PR says both pass.

Review threads

The listing returned 0 of my own threads, and there are no unresolved threads on the PR. I resolved none and re-affirmed none.

Comment thread install-cli.sh Resolved
@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @paveltiunov's task in 1m 30s —— View job


No blocking issues: 0 high, 0 medium, 0 inline. 1 low note.

Review details
  • Gather context and diff
  • Review installers, CLI, tests, docs
  • Reconcile prior review threads
  • Post review

Verified

  • install-cli.sh:94-108 release_urls: the fields come in GitHub's real order (tag_name, draft, prerelease, then assets, then body), so the per-release state in awk stays correct. Escaped JSON in body (\"tag_name\") doesn't match the grep -oE pattern. The substr suffix check is correctly 1-indexed. sort -t. -kNnr orders 1.10.x above 1.9.x, and the URL after the third dot doesn't change the numeric key.
  • Fallbacks: a 403 from rate limiting makes curl -f / wget -q fail, which leaves $tmp/urls missing. [ ! -s ] then falls back to releases/latest. A pinned CUBE_VERSION skips the API entirely.
  • GITHUB_TOKEN is sent only for URLs matching https://api.github.com/* (install-cli.sh:113, install-cli.ps1:28). It never goes to a mirror or to the download URLs.
  • install-cli.ps1:31-32 assigns the result before piping it on, which works around how PowerShell 5.1 passes arrays through the pipeline. [version] sorting is numeric.
  • update.rs: newest_installable filters drafts and prereleases, and treats a non-uploaded asset as missing. asset_for_this_platform uses the same asset() check, so the bail! in commands/update.rs:41 can only trigger on platforms with no CLI build. newer_than and version_key share one parser.
  • Docs requirement met: docs-mintlify/reference/cli.mdx covers how a release is picked, plus CUBE_RELEASES_URL and GITHUB_TOKEN.
  • CI: the cube-cli.yml path filters already include install-cli.sh / install-cli.ps1, so the new installers job runs on installer-only changes.

Low (not posted inline)

  • install-cli.sh:101-103: when a release object has no draft or prerelease field, install-cli.sh treats it as not stable. install-cli.ps1 and the Rust CLI treat a missing field as false. GitHub always sends both fields, so this only affects a hand-rolled CUBE_RELEASES_URL mirror, and it fails safe by falling back to releases/latest. Mentioned only so the three implementations don't drift further apart.

Not run

  • I couldn't run rust/cube-cli/tests/installers.sh or cargo test, because the sandbox didn't allow either command. CI's installers and build-and-test jobs cover both.

Review threads

  • The listing returned 0 of my own threads, so there were none to resolve and none to re-affirm.

@paveltiunov
paveltiunov merged commit 5104854 into master Oct 27, 2026
17 checks passed
@paveltiunov
paveltiunov deleted the pavel-claude/optimistic-cannon-dgpym6 branch October 27, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Issues that require a documentation improvement rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants