From 1253a3b51e98a6ba43b063ca623f90819c29cda5 Mon Sep 17 00:00:00 2001 From: Javier Castiarena Date: Tue, 21 Apr 2026 09:43:44 -0300 Subject: [PATCH] fix(rds-postgres-server): skip db_name check on unlink of never-created link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a link transitions to a failed state before fully materializing, its .link.attributes never receives the db_name parameter. Subsequent unlink actions then hit `ERROR: db_name is required to create a link` and the link gets stuck — user cannot retry nor remove it cleanly. Mirror the pattern from rds-postgres-db/scripts/aws/build_context (which sets LINK_NEVER_CREATED=true when .type == "delete" and there is no server hostname): on a delete action with missing db_name, log a warning and exit cleanly instead of failing the unlink workflow. The error is preserved for create/link actions, where missing db_name is still a user error. Reproduced on the Galicia POC (CLIEN-759): a second link test with invalid parameters left the link in failed state; the unlink could never clean it up. Pairs with #12 (TFSTATE_BUCKET propagation). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../scripts/aws/build_permissions_context | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/databases/rds-postgres-server/scripts/aws/build_permissions_context b/databases/rds-postgres-server/scripts/aws/build_permissions_context index 2a2b799..ecdf72f 100755 --- a/databases/rds-postgres-server/scripts/aws/build_permissions_context +++ b/databases/rds-postgres-server/scripts/aws/build_permissions_context @@ -36,6 +36,7 @@ fi # --- Read service outputs (set by write_service_outputs after RDS creation) - SERVICE_ID=$(echo "$CONTEXT" | jq -r '.service.id') +ACTION_TYPE=$(echo "$CONTEXT" | jq -r '.type // ""') SERVICE_ATTRS=$(echo "$CONTEXT" | jq -r '.service.attributes // {}') DB_HOST=$(echo "$SERVICE_ATTRS" | jq -r '.hostname // ""') @@ -77,6 +78,10 @@ LINK_ATTRS=$(echo "$CONTEXT" | jq -r '(.link.attributes // {}) * (.parameters // DB_NAME=$(echo "$LINK_ATTRS" | jq -r '.db_name // ""') if [ -z "$DB_NAME" ]; then + if [ "$ACTION_TYPE" = "delete" ]; then + echo "WARNING: unlink without db_name — link likely never fully created. Exiting cleanly." + exit 0 + fi echo "ERROR: db_name is required to create a link" >&2 exit 1 fi