Skip to content

fix: surface API errors in okta_group_memberships Update - #2921

Open
aknight-bw wants to merge 2 commits into
okta:masterfrom
Bandwidth:fix/gh-2866-silent-403-group-memberships-update
Open

fix: surface API errors in okta_group_memberships Update#2921
aknight-bw wants to merge 2 commits into
okta:masterfrom
Bandwidth:fix/gh-2866-silent-403-group-memberships-update

Conversation

@aknight-bw

Copy link
Copy Markdown

Fixes #2866

resourceGroupMembershipsUpdate calls diag.FromErr(err) for both the addGroupMembers and removeGroupMembers error paths but discards the return value in both cases. Any API error is therefore
silently 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) on PUT /api/v1/groups/{groupId}/users/{userId} for any user who does not hold that
role. 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 notices
the membership never appeared in Okta.

Changes

  • Add return before both diag.FromErr(err) calls in resourceGroupMembershipsUpdate so API errors are propagated and the apply fails with a visible diagnostic.
  • Add 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 an E0000006
    error to surface (step 2).

Testing

  • make build and make 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 apply
    reports success instead.

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
@github-actions
github-actions Bot requested a review from aditya-okta August 5, 2026 18:35
…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.
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.

Silent 403 when okta token does not have correct permissions when managing group membership

1 participant