Skip to content

group_settings: remove from state on 404 instead of erroring during read#30

Open
akemner-figma wants to merge 2 commits into
SamuZad:mainfrom
akemner-figma:fix-group-settings-404-remove-from-state
Open

group_settings: remove from state on 404 instead of erroring during read#30
akemner-figma wants to merge 2 commits into
SamuZad:mainfrom
akemner-figma:fix-group-settings-404-remove-from-state

Conversation

@akemner-figma

Copy link
Copy Markdown

Problem

When the group underlying a googleworkspace_group_settings resource is deleted outside Terraform, the next plan/refresh fails hard on the settings read:

Error when reading or editing … 404

Because the resource is never dropped from state, the plan cannot proceed, and the only recovery is a manual terraform state rm.

Root cause

resourceGroupSettingsRead returns the group Get error via diag.FromErr(err) for every error, including a 404. The sibling googleworkspace_group resource already handles this correctly by routing the same call through handleNotFoundError (which does d.SetId("") and returns), but group_settings does not.

Fix

Route the group Get 404 in resourceGroupSettingsRead through handleNotFoundError(err, d, d.Get("email").(string)), mirroring resourceGroupRead. Non-404 errors (and the local strconv.ParseBool errors) are unchanged.

Test

Adds TestAccResourceGroupSettings_disappears: creates a group + settings, deletes the group out-of-band via the Directory API, and asserts the refresh drops the settings from state and yields a non-empty plan. Without the fix this step errors on the 404.

Notes

  • No schema or config changes; behavior change is limited to the deleted-outside-Terraform case.
  • This is the standard plugin behavior — HashiCorp's guidance and the framework docs both say Read should remove a resource from state when it no longer exists; resource_group in this provider already does so.

akemner-figma added a commit to akemner-figma/terraform-provider-googleworkspace that referenced this pull request Jul 18, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
akemner-figma added a commit to akemner-figma/terraform-provider-googleworkspace that referenced this pull request Jul 18, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@akemner-figma
akemner-figma force-pushed the fix-group-settings-404-remove-from-state branch from 7340359 to fd148a0 Compare July 18, 2026 23:49
akemner-figma and others added 2 commits July 18, 2026 18:42
When the underlying group is deleted outside Terraform, resourceGroupSettingsRead
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`.

Route the group Get 404 through handleNotFoundError (which does d.SetId("")),
matching the existing behavior of resource_group. Non-404 errors are unchanged.

Adds TestAccResourceGroupSettings_disappears covering out-of-band group deletion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@akemner-figma
akemner-figma force-pushed the fix-group-settings-404-remove-from-state branch from fd148a0 to dfe19f9 Compare July 19, 2026 00:42
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