From 16da9e12b6272a7ac103eff1e192b3b49ac893c9 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Sat, 7 Feb 2026 20:31:35 -0800 Subject: [PATCH] fix: make teardown script resilient to already-deleted Neon branches Skip gracefully instead of failing when NEON_BRANCH_ID is missing or when the Neon branch has already been deleted / doesn't exist. --- .superset/teardown.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.superset/teardown.sh b/.superset/teardown.sh index 66b2c30e23c..ad02fb46015 100755 --- a/.superset/teardown.sh +++ b/.superset/teardown.sh @@ -135,8 +135,8 @@ step_delete_neon_branch() { BRANCH_ID="${NEON_BRANCH_ID:-}" if [ -z "$BRANCH_ID" ]; then - error "No NEON_BRANCH_ID found in .env; cannot delete branch" - return 1 + warn "No NEON_BRANCH_ID found in .env; skipping branch deletion" + return 0 fi if ! command -v neonctl &> /dev/null; then @@ -146,11 +146,18 @@ step_delete_neon_branch() { WORKSPACE_NAME="${SUPERSET_WORKSPACE_NAME:-$(basename "$PWD")}" - if neonctl branches delete "$BRANCH_ID" --project-id "$NEON_PROJECT_ID" --force; then + local output + if output=$(neonctl branches delete "$BRANCH_ID" --project-id "$NEON_PROJECT_ID" --force 2>&1); then success "Neon branch deleted: $WORKSPACE_NAME ($BRANCH_ID)" else - error "Failed to delete Neon branch: $WORKSPACE_NAME ($BRANCH_ID)" - return 1 + # Treat "not found" / "already deleted" as a skip, not a failure + if echo "$output" | grep -qiE "not found|does not exist|already deleted|404"; then + warn "Neon branch already deleted or not found: $WORKSPACE_NAME ($BRANCH_ID)" + else + error "Failed to delete Neon branch: $WORKSPACE_NAME ($BRANCH_ID)" + error "Output: $output" + return 1 + fi fi return 0