Skip to content

Commit 30aafb6

Browse files
committed
fix(tools.func): handle GitHub 300 Multiple Choices in tarball mode
When a GitHub repository has both a branch and a tag with the same name (e.g. Pangolin's '1.12.3'), the API's tarball_url and zipball_url return HTTP 300 Multiple Choices instead of a redirect. curl saves the JSON response body as the file, causing 'gzip: stdin: not in gzip format' when tar tries to extract. This fix uses the explicit refs/tags/ URL format instead: https://github.com/$repo/archive/refs/tags/$tag.tar.gz This URL always returns a proper 302 redirect to the tarball, avoiding the ambiguity between branch and tag names. Fixes: #9694
1 parent fd8a305 commit 30aafb6

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

misc/tools.func

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,9 +1535,10 @@ check_for_gh_release() {
15351535
# ------------------------------------------------------------------------------
15361536
create_self_signed_cert() {
15371537
local APP_NAME="${1:-${APPLICATION}}"
1538-
local CERT_DIR="/etc/ssl/${APP_NAME}"
1539-
local CERT_KEY="${CERT_DIR}/${APP_NAME}.key"
1540-
local CERT_CRT="${CERT_DIR}/${APP_NAME}.crt"
1538+
local APP_NAME_LC=$(echo "${APP_NAME,,}" | tr -d ' ')
1539+
local CERT_DIR="/etc/ssl/${APP_NAME_LC}"
1540+
local CERT_KEY="${CERT_DIR}/${APP_NAME_LC}.key"
1541+
local CERT_CRT="${CERT_DIR}/${APP_NAME_LC}.crt"
15411542

15421543
if [[ -f "$CERT_CRT" && -f "$CERT_KEY" ]]; then
15431544
return 0
@@ -1728,12 +1729,13 @@ function fetch_and_deploy_gh_release() {
17281729

17291730
### Tarball Mode ###
17301731
if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then
1731-
url=$(echo "$json" | jq -r '.tarball_url // empty')
1732-
[[ -z "$url" ]] && url="https://github.com/$repo/archive/refs/tags/v$version.tar.gz"
1732+
# GitHub API's tarball_url/zipball_url can return HTTP 300 Multiple Choices
1733+
# when a branch and tag share the same name. Use explicit refs/tags/ URL instead.
1734+
local direct_tarball_url="https://github.com/$repo/archive/refs/tags/$tag_name.tar.gz"
17331735
filename="${app_lc}-${version}.tar.gz"
17341736

1735-
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$url" || {
1736-
msg_error "Download failed: $url"
1737+
curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url" || {
1738+
msg_error "Download failed: $direct_tarball_url"
17371739
rm -rf "$tmpdir"
17381740
return 1
17391741
}

0 commit comments

Comments
 (0)