Skip to content

fix: handle unbound variable for stable parameter in verify_public_ecr and verify_dockerhub#1138

Merged
TheanLim merged 1 commit into
aws:mainlinefrom
TheanLim:fixVerifyEcr
May 14, 2026
Merged

fix: handle unbound variable for stable parameter in verify_public_ecr and verify_dockerhub#1138
TheanLim merged 1 commit into
aws:mainlinefrom
TheanLim:fixVerifyEcr

Conversation

@TheanLim

@TheanLim TheanLim commented May 14, 2026

Copy link
Copy Markdown
Contributor

Summary

publish.sh runs with set -euo pipefail. The -u flag causes bash to treat any reference to an unset variable as an error and immediately exit the script.

verify_public_ecr and verify_dockerhub both assigned their first positional parameter with stable=${1}. When either function is called without an argument, $1 is unset and bash aborts the script with unbound variable before the verification logic runs.

Changed stable=${1} to stable=${1:-} in both functions. The :- default value syntax tells bash to use an empty string if $1 is unset, satisfying -u without changing behavior when the argument is provided.

Testing

A snippet to test the behavior

#!/bin/bash
set -euo pipefail

echo "=== BEFORE fix: stable=\${1} ==="
( set -euo pipefail; stable=${1}; echo "stable=${stable}" ) && echo "OK" || echo "FAILED: unbound variable"

echo ""
echo "=== AFTER fix: stable=\${1:-} ==="
( set -euo pipefail; stable=${1:-}; echo "stable=${stable}" ) && echo "OK: stable is empty string, no error"

Output:

./snippet.sh            
=== BEFORE fix: stable=${1} ===
./test.sh: line 5: 1: unbound variable
FAILED: unbound variable

=== AFTER fix: stable=${1:-} ===
stable=
OK: stable is empty string, no error

Description for the changelog

fix: handle unbound variable for stable parameter in verify_public_ecr and verify_dockerhub

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@TheanLim TheanLim marked this pull request as ready for review May 14, 2026 18:32
@TheanLim TheanLim requested a review from a team as a code owner May 14, 2026 18:32
@TheanLim TheanLim changed the title fix: handle unbound variable for stable parameter in verify_public_ecr fix: handle unbound variable for stable parameter in verify_public_ecr and verify_dockerhub May 14, 2026
@TheanLim TheanLim merged commit 9fd4960 into aws:mainline May 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants