fix(request_condition): save state before post-create calls - #2900
Open
exitcode0 wants to merge 1 commit into
Open
fix(request_condition): save state before post-create calls#2900exitcode0 wants to merge 1 commit into
exitcode0 wants to merge 1 commit into
Conversation
The Create function for okta_request_condition only persisted state after every API call succeeded. When the initial POST created the condition but a follow-up call failed (activation when the config sets status = "ACTIVE", or the priority PATCH), Create returned error diagnostics without ever calling resp.State.Set, so Terraform recorded nothing. The condition was left orphaned in Okta as an unmanaged INACTIVE draft, and the next apply created a duplicate. Persist the created condition to state immediately after the create POST succeeds, and refresh the saved state after successful activation, so a mid-Create failure marks the resource as tainted instead of orphaning it. State saved during Create is preserved by Terraform even when error diagnostics are returned. Fixes okta#2899
exitcode0
force-pushed
the
fix/request-condition-orphan-on-create-failure
branch
from
July 29, 2026 05:03
cb16b7e to
a547761
Compare
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 #2899
Createforokta_request_conditionmakes up to three API calls (create POST, activate when the config setsstatus = "ACTIVE", and a follow-up priority PATCH), but only persisted state after all of them succeeded. If the POST created the condition and a later call failed (e.g. the transport giving up after repeated 429s in a rate-limited org), Create returned error diagnostics without ever callingresp.State.Set:terraform applycreated a duplicate condition on the appChanges
Createnow persists the created condition to state immediately after the create POST succeeds, before the activate callDeletedeactivates correctly) if the priority PATCH afterwards failsstatus/priorityvalues remain available to the existing follow-up logic; the successful path still ends with the same final fullresp.State.Setas beforeState saved during Create is preserved by Terraform even when error diagnostics are returned, so a mid-Create failure now marks the resource as tainted (replaced on the next apply) instead of orphaning it. See the plugin framework Create documentation.
Testing
go build ./...,go vet ./okta/services/governance/,gofmt— cleanOKTA_VCR_TF_ACC=play OKTA_VCR_CASSETTE=oie-00):TestAccRequestConditionResource_Status(create withstatus = "ACTIVE", deactivate, reactivate — exercises both new state-save blocks) — PASSTestAccRequestConditionResource_Issue2780— PASSTestAccDataSourceOktaRequestCondition_read,TestAccRequestConditionResource_basic,TestAccRequestConditionResource_Issue2510,TestAccRequestConditionResource_Priorityfail identically on unmodifiedmaster(pre-existing cassette mismatches), so no regression from this changeNotes
vcrManager.Cassettes()returns early if the idaas cassette directory for the test is missing, so governance tests silently run zero cassettes unlessOKTA_VCR_CASSETTEis set explicitly. Not addressed in this PR.