Skip to content

site: install.sh: do not treat an unresolved latest redirect as a version - #958

Open
pilotwaffle wants to merge 1 commit into
google:mainfrom
pilotwaffle:install-reject-latest
Open

pilotwaffle wants to merge 1 commit into
google:mainfrom
pilotwaffle:install-reject-latest

Conversation

@pilotwaffle

Copy link
Copy Markdown

When the releases/latest redirect doesn't resolve to a tag (a proxy that drops redirects, a network hiccup, a rate limit), curl -w "%{url_effective}" returns .../releases/latest. The sed then yields latest.

Both guards (lines 28 and 32) reject only an empty value and releases. So latest passes, the API fallback never runs, and the script fails with a misleading download error:

Found latest version: latest
Downloading https://github.com/google/agentmesh/releases/download/latest/checksums.txt...
Error: Failed to download https://github.com/google/agentmesh/releases/download/latest/checksums.txt

This change adds || [ "$VERSION" = "latest" ] to both guards. The first lets the API fallback run; the second gives a clear error if the fallback also finds nothing.

Tested with a stubbed curl, redirect unresolved in every case:

API result Before After
Returns v0.2.0 Uses latest, download fails Uses v0.2.0
Returns nothing Uses latest, download fails Error: Could not find the latest release.

bash -n passes. Normal installs, where the redirect resolves, are unchanged.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DDsLaTvKmrMTKwoWFjAo1k

…sion

When the releases/latest redirect does not resolve to a tag, the url_effective
ends in /latest and the script took "latest" as the version: the API fallback
never ran and the download failed with a misleading URL. Reject "latest" in
both guards, so the fallback runs and an empty result gives a clear error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DDsLaTvKmrMTKwoWFjAo1k
@pilotwaffle
pilotwaffle requested a review from aojea as a code owner November 26, 2026 23:24
@google-cla

google-cla Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the install.sh script to handle cases where the fetched release version is "latest", falling back to the GitHub API or failing gracefully. The review feedback requests adding a regression test using Bats to verify this fallback and error behavior, as required by the repository's style guide for bug fixes.

Comment thread site/static/install.sh
echo "Fetching latest release information..."
VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/${REPO}/releases/latest" | sed 's|.*/||' || true)
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ] || [ "$VERSION" = "latest" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Section 3: Test coverage must follow the pyramid

According to Rule 3 of Section 3, any bug fix must be accompanied by a regression test at the lowest adequate layer. Since this PR fixes a bug in the install.sh script where an unresolved redirect results in a failed download of a malformed URL, please add a regression test.

Since this is a bash script, the appropriate layer is an E2E test using Bats (e.g., in tests/e2e/). The test should stub curl to simulate an unresolved redirect (returning latest or failing) and verify that:

  1. The script correctly falls back to the GitHub API if that succeeds.
  2. The script fails with the clear error message Error: Could not find the latest release. if the API fallback also fails, rather than attempting to download from a malformed URL.
References
  1. Section 3, Rule 3: Every behavior change ships with a test at the lowest adequate layer. Flag missing regression tests for bug fixes. A PR whose description says 'fix', 'bypass', 'canonicalize', 'race', 'leak' or similar must add a test that fails on the parent commit. (link)

This branch has not been deployed

No deployments
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.

1 participant