Skip to content

Commit 078bd8a

Browse files
owineclaude
andcommitted
fix: redirect ssh_retry diagnostic messages to stderr
**Root Cause**: The ssh_retry function was outputting diagnostic messages to stdout, which were being captured along with the actual command output when using command substitution. This caused the CURRENT_SHA validation to fail because the captured output contained multiple lines: SSH Attempt 1 of 3 5521f2e2c49ddf933f160e7e5b6da7799fe5c4aa ✅ SSH command succeeded on attempt 1 The regex validation `^[a-fA-F0-9]{40}$` failed on this multi-line output, causing CURRENT_SHA to be set to "unknown", which triggered the "first deployment" logic and skipped stack removal detection entirely. **Impact**: Removed stacks were not being cleaned up because the detection was always being skipped due to the invalid SHA format. **Fix**: Redirect all diagnostic echo statements in ssh_retry to stderr using `>&2`. This ensures only the actual command output is captured in stdout, allowing proper SHA validation. **Test Plan**: - Verify deploy runs capture correct CURRENT_SHA - Confirm stack removal detection no longer skips - Validate removed stacks are properly cleaned up Changes: - Add >&2 to all echo statements in ssh_retry function (8 instances) - Diagnostic messages now appear in logs but don't pollute stdout - Command output captured cleanly for variable assignment Follows systematic debugging process from superpowers:systematic-debugging. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent ce533ce commit 078bd8a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,30 +267,30 @@ jobs:
267267
local last_exit_code=1
268268
269269
while [ $attempt -le $max_attempts ]; do
270-
echo "SSH Attempt $attempt of $max_attempts"
270+
echo "SSH Attempt $attempt of $max_attempts" >&2
271271
if eval "$ssh_cmd"; then
272-
echo "✅ SSH command succeeded on attempt $attempt"
272+
echo "✅ SSH command succeeded on attempt $attempt" >&2
273273
return 0
274274
else
275275
last_exit_code=$?
276-
echo "❌ SSH command failed on attempt $attempt (exit code: $last_exit_code)"
276+
echo "❌ SSH command failed on attempt $attempt (exit code: $last_exit_code)" >&2
277277
278278
# Check for specific SSH errors
279279
case $last_exit_code in
280-
255) echo "SSH connection error - network/auth issue" ;;
281-
1) echo "General SSH error" ;;
282-
*) echo "Unknown error code: $last_exit_code" ;;
280+
255) echo "SSH connection error - network/auth issue" >&2 ;;
281+
1) echo "General SSH error" >&2 ;;
282+
*) echo "Unknown error code: $last_exit_code" >&2 ;;
283283
esac
284284
285285
if [ $attempt -lt $max_attempts ]; then
286-
echo "⏳ Waiting ${delay}s before SSH retry..."
286+
echo "⏳ Waiting ${delay}s before SSH retry..." >&2
287287
sleep $delay
288288
fi
289289
attempt=$((attempt + 1))
290290
fi
291291
done
292292
293-
echo "💥 SSH command failed after $max_attempts attempts (final exit code: $last_exit_code)"
293+
echo "💥 SSH command failed after $max_attempts attempts (final exit code: $last_exit_code)" >&2
294294
return $last_exit_code
295295
}
296296
EOF

0 commit comments

Comments
 (0)