Skip to content

fix: status field miss causing drift suppression - #1705

Draft
KartikJha wants to merge 1 commit into
mainfrom
esd-65986-actions-deploy-failing
Draft

fix: status field miss causing drift suppression#1705
KartikJha wants to merge 1 commit into
mainfrom
esd-65986-actions-deploy-failing

Conversation

@KartikJha

Copy link
Copy Markdown
Contributor

🔧 Changes

Fixes a silent no-drift bug where an auth0_action that failed to build would
appear healthy on subsequent terraform plan runs, making Terraform-driven
recovery impossible.

Root cause: status was not tracked in the auth0_action schema.
readAction() discarded it, so Terraform saw no diff after a failed build — plan
always reported "No changes."

Fix:

  • Added status as a Computed attribute on auth0_action (resource.go).
  • flattenAction() now stores the value returned by the API (flatten.go).
  • A CustomizeDiff hook forces replacement when status == "failed" and deploy == true:
    • d.SetNewComputed("status") creates the required diff entry (bare
      d.ForceNew errors without it on a Computed-only attribute).
    • d.ForceNew("status") marks the resource for replacement.
    • The deploy == true gate prevents non-deployed draft actions from looping in
      endless replace cycles.

After the fix, the next terraform plan against a failed action shows:

~ resource "auth0_action" "example" {
~ status = "failed" -> (known after apply) # forces replacement
}

and the next terraform apply re-triggers the build automatically.

No state migration needed. On first plan after provider upgrade, healthy
actions show + status = "built" (cosmetic); failed actions immediately show the
replacement plan.

🔬 Testing

Reproduced and verified against live tenant kartik-esd-57610.sus.auth0.com using
a 3-stage repro script (esd_65986_status_no_drift_repro/):

  1. terraform apply -var dep_mode=good → both actions reach status="built"
  2. terraform apply -var dep_mode=bad → UPDATE path, build fails, no SDKv2 taint,
    status="failed" on backend
  3. terraform plan -var dep_mode=bad:
    • Without fix: exits 0, "No changes" — bug confirmed
    • With fix: exits 2, shows status = "failed" -> (known after apply) # forces replacement — fix confirmed

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

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.

1 participant