From 8fb624dada9b06713b1f1a5e3aa3d1ce96ef790f Mon Sep 17 00:00:00 2001 From: Bryce Adelstein Lelbach aka wash Date: Wed, 8 Apr 2026 09:58:48 -0400 Subject: [PATCH] fix: handle GitHub API rate limits in install scripts The install scripts used `curl -s` which silently swallows HTTP errors. When the GitHub API returns a 403 (rate limit) or other failure, the scripts would either print a misleading "Could not find release" error or, in the case of install-latest-linux.sh, proceed with an empty URL. Switch to `curl -sf` so HTTP errors produce a non-zero exit code, and add explicit error handling with a clear message about rate limiting. Also add a missing empty-URL guard to install-latest-linux.sh. --- bin/install-latest-linux.sh | 15 +++++++++++++-- bin/install-latest.sh | 11 ++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/bin/install-latest-linux.sh b/bin/install-latest-linux.sh index da516c9ae..5ed29903c 100755 --- a/bin/install-latest-linux.sh +++ b/bin/install-latest-linux.sh @@ -1,8 +1,19 @@ #!/usr/bin/env bash set -eo pipefail -# Install the latest version of the Linux binary -DOWNLOAD_URL="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest | grep "browser_download_url.*linux.*amd64" | cut -d '"' -f 4)" +# Fetch release metadata from GitHub API +API_RESPONSE="$(curl -sf https://api.github.com/repos/brevdev/brev-cli/releases/latest 2>&1)" || { + echo "Error: Failed to fetch release info from GitHub API." >&2 + echo "This may be caused by rate limiting. Try again later or set a GITHUB_TOKEN." >&2 + exit 1 +} + +# Extract the download URL for linux/amd64 +DOWNLOAD_URL="$(echo "${API_RESPONSE}" | grep "browser_download_url.*linux.*amd64" | cut -d '"' -f 4)" +if [ -z "${DOWNLOAD_URL}" ]; then + echo "Error: Could not find release for linux amd64" >&2 + exit 1 +fi # Create temporary directory and ensure cleanup TMP_DIR="$(mktemp -d)" diff --git a/bin/install-latest.sh b/bin/install-latest.sh index 16f5c6343..1c6a13c66 100755 --- a/bin/install-latest.sh +++ b/bin/install-latest.sh @@ -9,10 +9,15 @@ case "${ARCH}" in aarch64) ARCH="arm64" ;; esac -# Get the appropriate download URL for this platform -DOWNLOAD_URL="$(curl -s https://api.github.com/repos/brevdev/brev-cli/releases/latest | grep "browser_download_url.*${OS}.*${ARCH}" | cut -d '"' -f 4)" +# Fetch release metadata from GitHub API +API_RESPONSE="$(curl -sf https://api.github.com/repos/brevdev/brev-cli/releases/latest 2>&1)" || { + echo "Error: Failed to fetch release info from GitHub API." >&2 + echo "This may be caused by rate limiting. Try again later or set a GITHUB_TOKEN." >&2 + exit 1 +} -# Verify we found a suitable release +# Extract the download URL for this platform +DOWNLOAD_URL="$(echo "${API_RESPONSE}" | grep "browser_download_url.*${OS}.*${ARCH}" | cut -d '"' -f 4)" if [ -z "${DOWNLOAD_URL}" ]; then echo "Error: Could not find release for ${OS} ${ARCH}" >&2 exit 1