Skip to content

Commit 31c8b53

Browse files
owineclaudehappy-otter
committed
fix(deployment): prevent shell glob expansion in deleted files JSON
Fix shell glob expansion bug in detect-removed-stacks.sh discovery analysis function that caused deployment failures when stacks were deleted. Problem: - JSON array ['["stack/compose.yaml"]'] passed to remote bash/zsh via SSH - Square brackets [] interpreted as glob pattern (character class matching) - On zsh with 'nomatch' option, this caused: "no matches found" error - Deployment failed when trying to detect and clean up removed stacks Root Cause: Line 208: The JSON string was passed as an unquoted argument to the remote shell, allowing glob expansion of the [] characters. Solution: Use single quotes around the SSH command and expand the JSON variable with double quotes to prevent local and remote shell glob expansion: 'ssh ... /bin/bash -s -- "'"$deleted_files_json"'"' This ensures: - JSON is expanded locally (before SSH) - Properly quoted for remote shell (prevents glob expansion) - Works with both bash and zsh on remote servers Testing: - Verified JSON parsing works correctly - Tested with zsh (previously failing shell) - Confirmed no glob expansion occurs Fixes: docker-zendc deployment failure run #20583514124 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <[email protected]> Co-Authored-By: Happy <[email protected]>
1 parent 46481ac commit 31c8b53

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

scripts/deployment/detect-removed-stacks.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ DETECT_DISCOVERY_EOF
205205
)
206206

207207
# Execute detection script on remote server
208-
echo "$detect_script" | ssh_retry 3 5 "ssh -o \"StrictHostKeyChecking no\" $SSH_USER@$SSH_HOST /bin/bash -s \"$deleted_files_json\""
208+
# Use single quotes around ssh command and expand JSON variable with double quotes
209+
# to prevent shell glob expansion of [] characters in the JSON array
210+
echo "$detect_script" | ssh_retry 3 5 'ssh -o "StrictHostKeyChecking no" '"$SSH_USER"'@'"$SSH_HOST"' /bin/bash -s -- "'"$deleted_files_json"'"'
209211
}
210212

211213
# === AGGREGATION FUNCTION ===

0 commit comments

Comments
 (0)