diff --git a/vault/identity_store_util.go b/vault/identity_store_util.go index 0426f53e6ce5f..668fabd5a4bec 100644 --- a/vault/identity_store_util.go +++ b/vault/identity_store_util.go @@ -923,16 +923,10 @@ func (i *IdentityStore) sanitizeAndUpsertGroup(group *identity.Group, memberGrou // Sanitize the group alias if group.Alias != nil { group.Alias.CanonicalID = group.ID - err = i.sanitizeAlias(group.Alias) if err != nil { return err } - - err = i.MemDBUpsertAliasInTxn(txn, group.Alias, true) - if err != nil { - return err - } } err = i.UpsertGroupInTxn(txn, group, true) @@ -1092,6 +1086,12 @@ func (i *IdentityStore) UpsertGroupInTxn(txn *memdb.Txn, group *identity.Group, // Increment the modify index of the group group.ModifyIndex++ + if group.Alias != nil { + err = i.MemDBUpsertAliasInTxn(txn, group.Alias, true) + if err != nil { + return err + } + } // Insert or update group in MemDB using the transaction created above err = i.MemDBUpsertGroupInTxn(txn, group) if err != nil {