Skip to content

Commit

Permalink
Merge pull request #1593 from manicminer/bugfix/group-owner-retry-on-…
Browse files Browse the repository at this point in the history
…duplicate-error

azuread_group: fix bug preventing creation retry when caller owner causes duplicate value error
  • Loading branch information
stephybun authored Jan 15, 2025
2 parents c8d89fc + 2d9e647 commit f5fb443
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/services/groups/group_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,14 +674,14 @@ func groupResourceCreate(ctx context.Context, d *pluginsdk.ResourceData, meta in
if response.WasBadRequest(resp.HttpResponse) && regexp.MustCompile(groupDuplicateValueError).MatchString(err.Error()) {
// Retry the group creation, without the calling principal as owner
ownersWithoutCallingPrincipal := make([]string, 0)
for _, o := range *properties.Owners_ODataBind {
for _, o := range pointer.From(properties.Owners_ODataBind) {
if o != callerODataId {
ownersWithoutCallingPrincipal = append(ownersWithoutCallingPrincipal, o)
}
}

// No point in retrying if the caller wasn't specified as an owner
if len(ownersWithoutCallingPrincipal) == len(pointer.From(properties.Owners)) {
if len(ownersWithoutCallingPrincipal) == len(pointer.From(properties.Owners_ODataBind)) {
log.Printf("[DEBUG] Not retrying group creation for %q as owner was not specified", displayName)
return tf.ErrorDiagF(err, "Creating group %q", displayName)
}
Expand Down

0 comments on commit f5fb443

Please sign in to comment.