From 7f6e473b4d0bc8c0e27ca5a0af20fb751e6337b3 Mon Sep 17 00:00:00 2001 From: MickLesk Date: Fri, 5 Dec 2025 20:48:58 +0100 Subject: [PATCH] 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 --- misc/tools.func | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/misc/tools.func b/misc/tools.func index dd35c5c7fd8..9c589482cde 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1728,12 +1728,13 @@ function fetch_and_deploy_gh_release() { ### Tarball Mode ### if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then - url=$(echo "$json" | jq -r '.tarball_url // empty') - [[ -z "$url" ]] && url="https://github.com/$repo/archive/refs/tags/v$version.tar.gz" + # GitHub API's tarball_url/zipball_url can return HTTP 300 Multiple Choices + # when a branch and tag share the same name. Use explicit refs/tags/ URL instead. + local direct_tarball_url="https://github.com/$repo/archive/refs/tags/$tag_name.tar.gz" filename="${app_lc}-${version}.tar.gz" - curl $download_timeout -fsSL -o "$tmpdir/$filename" "$url" || { - msg_error "Download failed: $url" + curl $download_timeout -fsSL -o "$tmpdir/$filename" "$direct_tarball_url" || { + msg_error "Download failed: $direct_tarball_url" rm -rf "$tmpdir" return 1 }