From 107d84026a74399ff1772fb00e982cc27c89a1f6 Mon Sep 17 00:00:00 2001 From: Vijay Govindarajan Date: Thu, 26 Mar 2026 18:07:30 -0700 Subject: [PATCH 1/2] fix: use python3 JSON parser in checkLatestRelease() instead of grep The grep pattern `"tag_name": "[^"]*"` assumes a space after the colon in the GitHub API JSON response. When GitHub returns compact/minified JSON without spaces, the pattern fails and the install script aborts with "Failed to check for the latest release." Replace grep+sed with python3's json module which handles both compact and formatted JSON reliably. python3 is already a prerequisite for the Docker setup scripts. Applied to both install.sh (CLI) and swarm.sh (Docker Swarm). Closes #8775 --- deployments/cli/community/install.sh | 2 +- deployments/swarm/community/swarm.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/cli/community/install.sh b/deployments/cli/community/install.sh index 582aa839413..806a3885bd3 100755 --- a/deployments/cli/community/install.sh +++ b/deployments/cli/community/install.sh @@ -57,7 +57,7 @@ function spinner() { function checkLatestRelease(){ echo "Checking for the latest release..." >&2 - local latest_release=$(curl -sSL https://api.github.com/repos/$GH_REPO/releases/latest | grep -o '"tag_name": "[^"]*"' | sed 's/"tag_name": "//;s/"//g') + local latest_release=$(curl -sSL https://api.github.com/repos/$GH_REPO/releases/latest | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) if [ -z "$latest_release" ]; then echo "Failed to check for the latest release. Exiting..." >&2 exit 1 diff --git a/deployments/swarm/community/swarm.sh b/deployments/swarm/community/swarm.sh index d496c25e6de..1e5dbf55177 100755 --- a/deployments/swarm/community/swarm.sh +++ b/deployments/swarm/community/swarm.sh @@ -38,7 +38,7 @@ EOF function checkLatestRelease(){ echo "Checking for the latest release..." >&2 - local latest_release=$(curl -s https://api.github.com/repos/$GH_REPO/releases/latest | grep -o '"tag_name": "[^"]*"' | sed 's/"tag_name": "//;s/"//g') + local latest_release=$(curl -s https://api.github.com/repos/$GH_REPO/releases/latest | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) if [ -z "$latest_release" ]; then echo "Failed to check for the latest release. Exiting..." >&2 exit 1 From be5118464a7433e947c23b57eff77a3366cc05d0 Mon Sep 17 00:00:00 2001 From: Vijay Govindarajan Date: Thu, 26 Mar 2026 18:17:35 -0700 Subject: [PATCH 2/2] fix: add python3 preflight check and address review feedback - Add explicit `command -v python3` check with clear error message - Separate `local` declaration from assignment (SC2155) - Use `-fsSL` curl flags and quote the URL - Quote `$latest_release` in echo Addresses review feedback from CodeRabbit. --- deployments/cli/community/install.sh | 9 +++++++-- deployments/swarm/community/swarm.sh | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/deployments/cli/community/install.sh b/deployments/cli/community/install.sh index 806a3885bd3..6006fde66a2 100755 --- a/deployments/cli/community/install.sh +++ b/deployments/cli/community/install.sh @@ -57,13 +57,18 @@ function spinner() { function checkLatestRelease(){ echo "Checking for the latest release..." >&2 - local latest_release=$(curl -sSL https://api.github.com/repos/$GH_REPO/releases/latest | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) + if ! command -v python3 &> /dev/null; then + echo "python3 is required but not installed. Please install Python 3 and try again." >&2 + exit 1 + fi + local latest_release + latest_release=$(curl -fsSL "https://api.github.com/repos/$GH_REPO/releases/latest" | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) if [ -z "$latest_release" ]; then echo "Failed to check for the latest release. Exiting..." >&2 exit 1 fi - echo $latest_release + echo "$latest_release" } function initialize(){ diff --git a/deployments/swarm/community/swarm.sh b/deployments/swarm/community/swarm.sh index 1e5dbf55177..abf17757c39 100755 --- a/deployments/swarm/community/swarm.sh +++ b/deployments/swarm/community/swarm.sh @@ -38,13 +38,18 @@ EOF function checkLatestRelease(){ echo "Checking for the latest release..." >&2 - local latest_release=$(curl -s https://api.github.com/repos/$GH_REPO/releases/latest | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) + if ! command -v python3 &> /dev/null; then + echo "python3 is required but not installed. Please install Python 3 and try again." >&2 + exit 1 + fi + local latest_release + latest_release=$(curl -fsSL "https://api.github.com/repos/$GH_REPO/releases/latest" | python3 -c "import sys,json; print(json.load(sys.stdin)['tag_name'])" 2>/dev/null) if [ -z "$latest_release" ]; then echo "Failed to check for the latest release. Exiting..." >&2 exit 1 fi - echo $latest_release + echo "$latest_release" } # Function to read stack name from env file