Skip to content

fix(rds-postgres-server): skip db_name check on unlink of never-created link#13

Merged
jcastiarena merged 1 commit intomainfrom
fix/rds-postgres-server-db-name-on-unlink
Apr 21, 2026
Merged

fix(rds-postgres-server): skip db_name check on unlink of never-created link#13
jcastiarena merged 1 commit intomainfrom
fix/rds-postgres-server-db-name-on-unlink

Conversation

@jcastiarena
Copy link
Copy Markdown
Contributor

Summary

build_permissions_context fails with ERROR: db_name is required to create a link when an unlink runs against a link that was never fully materialized — e.g. the create-link workflow failed partway through, so .link.attributes never received db_name. The link is then stuck: it can't retry, and it can't be cleaned up without manual state surgery.

Fix

Mirror the pattern already used by rds-postgres-db/scripts/aws/build_context, which handles the equivalent case with LINK_NEVER_CREATED=true when .type == "delete". For the server script, the minimal equivalent is: on a delete action with missing db_name, log a warning and exit cleanly instead of failing.

The error path is preserved for create/link actions — missing db_name there is still a real user error and should fail fast.

Repro

Exercised on the Galicia POC (CLIEN-759):

  1. Service rds-postgres-server created successfully.
  2. Link attempt with invalid parameters → link transitions to failed with no db_name in .link.attributes.
  3. Run unlink to clean up → workflow fails with ERROR: db_name is required to create a link.

With this change, step 3 emits a WARNING: unlink without db_name — link likely never fully created. Exiting cleanly. and returns exit 0, allowing the link to be removed.

Test plan

  • Create an rds-postgres-server and trigger a link with an invalid db_name to force a failed link
  • Run unlink on the failed link and confirm it completes cleanly (warning logged, no error)
  • Run unlink on a healthy link (with db_name present in attributes) and confirm unchanged behavior

Related

🤖 Generated with Claude Code

…ed link

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) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sebastiancorrea81 sebastiancorrea81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jcastiarena jcastiarena merged commit bc16d66 into main Apr 21, 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.

2 participants