Skip to content

fix(core): detect create-before-destroy replacements in drift - #319

Merged
viodid merged 3 commits into
InditexTech:mainfrom
Lostmanu:fix/create-before-destroy-drift
Oct 13, 2026
Merged

viodid merged 3 commits into
InditexTech:mainfrom
Lostmanu:fix/create-before-destroy-drift

Conversation

@Lostmanu

@Lostmanu Lostmanu commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

plan_to_drift drops replacements whose actions are ["create", "delete"]. When this is the only change, Terraform.drift returns in_sync=True despite the pending replacement.

Handle this order through the same branch as ["delete", "create"], preserving the existing summary format. Regression tests cover both replacement orders, normal and reversed values, and the Terraform.drift synchronization result.

Fixes #318.

Checklist

  • Commits are signed
  • Commit messages follow Conventional Commits
  • Documentation has been updated (if needed)
  • I have read and agree to the project's Code of Conduct
  • I have signed the Contributor License Agreement (CLA)

Additional context

Targeted validation, from core/:

uv run --no-sync pytest tests/infrastructure/terraform/test_utils.py tests/infrastructure/terraform/test_terraform.py::TestTerraformDrift -q

The new regression tests fail against the unchanged parser and pass with the fix. A local terraform_data plan generated by Terraform also reproduces the omitted replacement.

The broader Terraform and drift-service test run has the same pre-existing failures on the base commit and this patch. No additional failures were observed in that comparison.

@signoff-validator

signoff-validator Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Contribution License Agreement - Valid 🟢

All commits contain valid signoff. As a confirmation, remember that you are agreeing to our Contribution License Agreement.

@Lostmanu
Lostmanu marked this pull request as ready for review October 9, 2026 10:48
@Lostmanu
Lostmanu requested a review from a team as a code owner October 9, 2026 10:48
@Lostmanu
Lostmanu force-pushed the fix/create-before-destroy-drift branch from 60a028e to 7e14e11 Compare October 9, 2026 11:00
@viodid
viodid requested a balanced review from Copilot October 13, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix correctly addresses the omitted replacement case with comprehensive regression coverage.

0 open findings

What changed in this PR

Fixes #318 by recognizing create-before-destroy replacements during Terraform drift detection.

Changes:

  • Handles both Terraform replacement action orders.
  • Adds parser and synchronization regression tests.
File Description
core/​src/​infrastructure/​terraform/​utils.py Recognizes ["create", "delete"] replacements.
core/​tests/​infrastructure/​terraform/​test_utils.py Tests both replacement orders and reversal modes.
core/​tests/​infrastructure/​terraform/​test_terraform.py Verifies replacements report out-of-sync state.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@viodid
viodid merged commit fa21183 into InditexTech:main Oct 13, 2026
39 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.

[Bug] create-before-destroy replacements are omitted from drift

3 participants