okta_push_group: remove from state on 404 instead of erroring during read - #2892
Open
akemner-figma wants to merge 1 commit into
Open
okta_push_group: remove from state on 404 instead of erroring during read#2892akemner-figma wants to merge 1 commit into
akemner-figma wants to merge 1 commit into
Conversation
akemner-figma
force-pushed
the
fix-push-group-remove-from-state-on-404
branch
3 times, most recently
from
July 19, 2026 00:42
6cecc98 to
b36deea
Compare
…delete) When an okta_push_group mapping (or its source group) is deleted outside Terraform, Read returned the 404 as a fatal error, so plan/refresh failed and the resource was never dropped from state — the only recovery was a manual `terraform state rm`. Delete had the same gap: it would error if the mapping was already gone. Read now removes the resource from state on a 404; Delete now treats a 404 as already-deleted. Both match the idiom used by other framework resources (okta_identity_source_group, okta_group_owners). Non-404 errors are unchanged. Adds TestAccResourceOktaPushGroup_disappears covering the out-of-band deletion. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
akemner-figma
force-pushed
the
fix-push-group-remove-from-state-on-404
branch
from
July 22, 2026 06:45
b36deea to
f2b37fa
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.
Problem
When an
okta_push_groupmapping (or its source group) is deleted outside Terraform, the nextplan/refreshfails hard:Because the resource is never dropped from state, the plan cannot proceed, and the only recovery is a manual
terraform state rm. This is especially painful on locked-down/high-integrity backends where ad-hoc state surgery is restricted.Deletehas the same gap — it errors if the mapping is already gone.Root cause
pushGroupResource.Readdiscards the HTTP response and treats every error fromGetGroupPushMappingas fatal — there is no not-found branch, so a deleted mapping surfaces as a plan error instead of being reconciled as drift.Deletelikewise treats a 404 as a failure rather than an already-deleted no-op.Fix
Read: onhttp.StatusNotFound, callresp.State.RemoveResource(ctx)and return.Delete: treat a404from either the deactivate or delete call as already-deleted (return without error) — making delete idempotent.Non-404 errors are unchanged.
Precedent
This is the behavior the plugin framework documents for
Read:— plugin-framework Read recommendations
Resources in this provider already follow it — e.g.
okta_identity_source_groupandokta_group_ownerscallresp.State.RemoveResource(ctx)on a 404 inReadand tolerate a 404 inDelete. It's also the standard convention across the ecosystem: the SDKv2googleworkspace_groupresource, for instance, drops itself from state on a 404 (d.SetId("")). This change bringsokta_push_groupin line.Test
Adds
TestAccResourceOktaPushGroup_disappears, which deletes the mapping out-of-band via the API and asserts the refresh removes it from state and yields a non-empty plan. Without the fix this step errors on the 404.Notes