cowork: fix terraform rollback generator correctness and safety - #48
Draft
Coding-Dev-Tools wants to merge 3 commits into
Draft
cowork: fix terraform rollback generator correctness and safety#48Coding-Dev-Tools wants to merge 3 commits into
Coding-Dev-Tools wants to merge 3 commits into
Conversation
- Empty plans now short-circuit to '# No changes to roll back' instead of emitting a header plus a dangerous blanket 'terraform destroy -auto-approve && terraform apply -auto-approve' suggestion for a plan with no changes. - Replacements (create-before-delete / delete-before-create / replace) no longer produce contradictory destroy + apply commands for the same resource; they revert via apply of the previous config only. - Pure creates get destroy; pure deletes get an explicit restore comment before their apply. - Added regression tests (tests/test_rollback_safety.py); updated the empty-plan edge-case test to assert the new safe behavior. 125/125 green, ruff clean.
…ut accident; keep rollback safety fixes intact
🤖 Automated Code Review✅ Ruff Lint — No issues
|
All three parsers (terraform/cfn/pulumi) silently returned an empty plan for any well-formed JSON that was not a plan file, so the CLI reported "no changes" and exited 0 - a silent-green trap. Add PlanFormatError raised on structural mismatch, validated immediately after input load, and surface it in _load_plan as a red CLI error with exit 1. +13 regression tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two correctness/safety issues in
rollback.pyTerraform rollback generation:terraform destroy -auto-approve && terraform apply -auto-approvesuggestion even when there was nothing to roll back. Now short-circuits to a single# No changes to roll backline.create_before_delete/delete_before_create/replaceactions appeared in both the creates list (destroy) and the destructive list (apply), emitting destroy-then-apply for the same resource. Replacements now revert via a single apply of the previous config; pure creates get destroy, pure deletes get an explicit restore comment.Adds
tests/test_rollback_safety.pyregression tests and updates the empty-plan edge-case test. 125/125 tests green, ruff clean.