fix: surface API errors in okta_group_memberships Update - #2921
Open
aknight-bw wants to merge 2 commits into
Open
fix: surface API errors in okta_group_memberships Update#2921aknight-bw wants to merge 2 commits into
aknight-bw wants to merge 2 commits into
Conversation
resourceGroupMembershipsUpdate discarded the return value of diag.FromErr, causing Okta API errors (e.g. 403 on a group with an application administrator role binding) to be silently swallowed and reported as a clean apply. Adds return statements to propagate both addGroupMembers and removeGroupMembers errors. Adds TestAccResourceOktaGroupMemberships_Issue2866 to cover the error path in Update. Fixes okta#2866
…sue2866
The AI scrubbed cassettes were missing two interactions required by the
test framework's actual call sequence: the backoff GetGroup call inside
resourceGroupCreate, and the DELETE for user2 during destroy (Terraform
seeds the update ResourceData with the planned state before calling
UpdateContext, so user2 lands in state despite the 403).
Also corrects the ExpectError regex from E0000006 to the actual error
summary text exposed by the SDK ("You do not have permission to perform
the requested action"), and generates classic-00.yaml with the correct
classic-00.dne-okta.com hostname rather than a copy of the oie cassette.
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 #2866
resourceGroupMembershipsUpdatecallsdiag.FromErr(err)for both theaddGroupMembersandremoveGroupMemberserror paths but discards the return value in both cases. Any API error is thereforesilently swallowed: Terraform writes state as if the membership change landed and reports a clean apply.
A concrete trigger: a group with an Application Administrator role binding causes Okta to return
E0000006(403) onPUT /api/v1/groups/{groupId}/users/{userId}for any user who does not hold thatrole. Before this fix, that 403 produces
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.with no diagnostics. The drift is only discoverable on the next plan, and only if the user noticesthe membership never appeared in Okta.
Changes
returnbefore bothdiag.FromErr(err)calls inresourceGroupMembershipsUpdateso API errors are propagated and the apply fails with a visible diagnostic.TestAccResourceOktaGroupMemberships_Issue2866: a two-step acceptance test that creates a group with one member (step 1, succeeds) then attempts to add a second member expecting anE0000006error to surface (step 2).
Testing
make buildandmake lint: clean.OKTA_VCR_TF_ACC=play make test-play-vcr-acc TEST_FILTER=TestAccResourceOktaGroupMemberships_Issue2866: passes with the fix applied; without the fix the expected error is never surfaced and the applyreports success instead.