Skip to content

fix(toolkit-lib): clean up the diff change set when early validation fails - #1821

Open
lemon0333 wants to merge 1 commit into
aws:mainfrom
lemon0333:fix/diff-changeset-cleanup-on-validation-failure
Open

fix(toolkit-lib): clean up the diff change set when early validation fails#1821
lemon0333 wants to merge 1 commit into
aws:mainfrom
lemon0333:fix/diff-changeset-cleanup-on-validation-failure

Conversation

@lemon0333

Copy link
Copy Markdown

Fixes #1767

When a cdk diff change set fails early validation (e.g. a resource that already exists), createChangeSetAndCleanup in toolkit-lib's cfn-api.ts threw from waitAndThrowOnProblem before the change-set and empty-stack cleanup could run. That orphaned the change set and left a new stack stuck in REVIEW_IN_PROGRESS, which then blocked subsequent change-set creation and forced the user to delete it manually in the console.

This change runs the cleanup on the failure path too — deleting the change set and, for a brand new stack, the empty review stack — as a best-effort step that does not mask the original validation error. Successful diffs are unchanged.

Verified with a new unit test in diff.test.ts (change set fails validation → DeleteChangeSet and DeleteStack are called); the full diff.test.ts suite passes (22/22).

Checklist

  • This change contains a major version upgrade for a dependency and I confirm all breaking changes are addressed
    • Release notes for the new version:

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

…fails

When a diff change set fails early validation (for example a resource that
already exists), `waitAndThrowOnProblem` threw before the change-set and
empty-stack cleanup ran, orphaning the change set and leaving a new stack
stuck in REVIEW_IN_PROGRESS, which then blocked subsequent change-set
creation on that stack.

Run the cleanup on the failure path too (best-effort, without masking the
original error) so a failed diff no longer leaks the change set or the empty
review stack.

Fixes aws#1767
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cli): changeset fails to delete when pre-deployment validation fails

1 participant