Skip to content

Commit 71dcec7

Browse files
authored
Update utils.bash
1 parent 8e72f4e commit 71dcec7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/utils.bash

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,23 @@ sort_versions() {
4646
}
4747

4848
fetch_all_assets() {
49-
curl -s -H "Accept: application/vnd.github.v3+json" \
50-
https://api.github.com/repos/${GH_REPO}/releases |
51-
jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"'
49+
local response
50+
response=$(curl "${curl_opts[@]}" -H "Accept: application/vnd.github.v3+json" \
51+
"https://api.github.com/repos/${GH_REPO}/releases")
52+
53+
# Check for GitHub API error (e.g., rate limit exceeded)
54+
if echo "$response" | jq -e 'type == "object" and has("message")' >/dev/null; then
55+
local message
56+
message=$(echo "$response" | jq -r '.message')
57+
fail "GitHub API error: $message"
58+
fi
59+
60+
# Validate it's an array
61+
if ! echo "$response" | jq -e 'type == "array"' >/dev/null; then
62+
fail "Unexpected GitHub response (not a release list array): $response"
63+
fi
64+
65+
echo "$response" | jq -r '.[0].assets[] | "\(.name) \(.browser_download_url)"'
5266
}
5367

5468
validate_platform() {

0 commit comments

Comments
 (0)