Repository navigation
site: install.sh: do not treat an unresolved latest redirect as a version - #958
pilotwaffle wants to merge 1 commit into
Conversation
…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
|
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. |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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:
- The script correctly falls back to the GitHub API if that succeeds.
- 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
- 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)
When the
releases/latestredirect doesn't resolve to a tag (a proxy that drops redirects, a network hiccup, a rate limit),curl -w "%{url_effective}"returns.../releases/latest. Thesedthen yieldslatest.Both guards (lines 28 and 32) reject only an empty value and
releases. Solatestpasses, the API fallback never runs, and the script fails with a misleading download error: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:v0.2.0latest, download failsv0.2.0latest, download failsError: Could not find the latest release.bash -npasses. Normal installs, where the redirect resolves, are unchanged.🤖 Generated with Claude Code
https://claude.ai/code/session_01DDsLaTvKmrMTKwoWFjAo1k