diff --git a/lib/utils.bash b/lib/utils.bash index cc716cb..05e434c 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -46,9 +46,17 @@ sort_versions() { } fetch_all_assets() { - curl -s -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${GH_REPO}/releases | - jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"' + local releases_json + releases_json="$(curl -s -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${GH_REPO}/releases)" + + # Validate that the response is an array (successful), otherwise print and fail + if ! echo "$releases_json" | jq -e 'type == "array"' >/dev/null; then + echo "$releases_json" | jq '.' # Optionally print error for debugging + fail "GitHub API did not return a valid releases array - likely rate-limited or network error." + fi + + echo "$releases_json" | jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"' } validate_platform() {