From e91e0e2543ec93fd9ce4d44651d832b3e6066be8 Mon Sep 17 00:00:00 2001 From: Dzmitry Kishylau Date: Thu, 5 Sep 2024 15:52:13 -0700 Subject: [PATCH] [fix] Ignore 404s when revoking permissions --- internal/provider/permissions/resource.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/provider/permissions/resource.go b/internal/provider/permissions/resource.go index 4c082a3..44f6588 100644 --- a/internal/provider/permissions/resource.go +++ b/internal/provider/permissions/resource.go @@ -191,6 +191,11 @@ func (r *permissionResource) revokePermission(ctx context.Context, subject permi request := api.NewPermissionsRevokePostRequest(createNewAPIPermissionsSubject(subject), createNewAPIPermissionsObject(object)) _, httpResponse, err := r.client.PermissionsAPI.PermissionsRevokePost(ctx).PermissionsRevokePostRequest(*request).Execute() if err != nil { + if httpResponse != nil && httpResponse.StatusCode == 404 { + // If the permission does not exist, we can ignore the error. + tflog.Info(ctx, "Permission not found", map[string]any{"id": permissionID}) + return diags + } diags.AddError( "Error deleting permission", "Could not delete permission with ID "+permissionID+": "+err.Error(),