Skip to content

Commit 3998e88

Browse files
fix(scripts): detect failures in publish_bottlecap_sandbox.sh (#1191)
## Overview `publish_bottlecap_sandbox.sh` would print ``` DONE: Published version of layer ... ``` even when the `aws-vault`/`aws` call failed, because pipeline failures were not propagated and `NEW_VERSION` was silently empty. Changes: - Replace `set -e` with `set -eo pipefail` so any failure in the `aws-vault | jq` pipeline aborts the script immediately - Add explicit validation: if `NEW_VERSION` is empty or `null` after the publish call, print `ERROR:` and exit 1 instead of a misleading success message - Fix unquoted `$ARCHITECTURE`, `$REGION` variables (shellcheck warnings) ## Testing Verified locally by running the script without `aws` in `$PATH` — the script now exits with `ERROR: Failed to publish layer ...` instead of `DONE: Published version of layer ...`.
1 parent 8de97e0 commit 3998e88

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

scripts/publish_bottlecap_sandbox.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# ARCHITECTURE - Which architecture to build for (amd64 or arm64). The default is amd64.
1313
# RELEASE_CANDIDATE - If true, publish as a release candidate to us-east-1. The default is false.
1414

15-
set -e
15+
set -eo pipefail
1616

1717
_init_arg(){
1818
if [ "$ARCHITECTURE" == "amd64" ]; then
@@ -24,7 +24,7 @@ _init_arg(){
2424
LAYER_PATH=".layers/datadog_extension-arm64.zip"
2525
LAYER_NAME="Datadog-Bottlecap-Beta-ARM"
2626
fi
27-
if [ -z $ARCHITECTURE ]; then
27+
if [ -z "$ARCHITECTURE" ]; then
2828
echo "No architecture specified, defaulting to amd64"
2929
ARCHITECTURE="amd64"
3030
fi
@@ -33,7 +33,7 @@ _init_arg(){
3333
LAYER_NAME+="-$SUFFIX"
3434
fi
3535

36-
if [ -z $REGION ]; then
36+
if [ -z "$REGION" ]; then
3737
echo "No region specified, defaulting to us-east-1"
3838
REGION="us-east-1"
3939
fi
@@ -44,7 +44,11 @@ publish(){
4444
NEW_VERSION=$(aws-vault exec sso-serverless-sandbox-account-admin -- aws lambda publish-layer-version --layer-name "${LAYER_NAME}" \
4545
--description "Datadog Bottlecap Beta" \
4646
--zip-file "fileb://${LAYER_PATH}" \
47-
--region $REGION | jq -r '.Version')
47+
--region "$REGION" | jq -r '.Version')
48+
if [ -z "$NEW_VERSION" ] || [ "$NEW_VERSION" = "null" ]; then
49+
echo "ERROR: Failed to publish layer $LAYER_NAME to region $REGION"
50+
exit 1
51+
fi
4852
echo "DONE: Published version $NEW_VERSION of layer $LAYER_NAME to region $REGION"
4953
}
5054

0 commit comments

Comments
 (0)