VAULT-22030 update error message when from entity isn't found as part of automated entity merge (#24188)

* VAULT-22030 update error message when from entity isn't found as part of automated entity merge

* VAULT-22030 add extra info
This commit is contained in:
Violet Hynes
2023-11-20 10:45:36 -05:00
committed by GitHub
parent 53040690a2
commit d2afea92a1

View File

@@ -883,6 +883,15 @@ func (i *IdentityStore) mergeEntity(ctx context.Context, txn *memdb.Txn, toEntit
}
if fromEntity == nil {
// If forceMergeAliases is true, and we didn't find a fromEntity, then something
// is wrong with storage. This function was called as part of an automated
// merge from CreateOrFetchEntity or Invalidate to repatriate an alias with its 'true'
// entity. As a result, the entity _should_ exist, but we can't find it.
// MemDb may be in a bad state, because fromEntity should be non-nil in the
// automated merge case.
if forceMergeAliases {
return fmt.Errorf("fromEntity %s was not found in memdb as part of an automated entity merge into %s; storage/memdb may be in a bad state", fromEntityID, toEntity.ID), nil, nil
}
return errors.New("entity id to merge from is invalid"), nil, nil
}
@@ -995,6 +1004,15 @@ func (i *IdentityStore) mergeEntity(ctx context.Context, txn *memdb.Txn, toEntit
}
if fromEntity == nil {
// If forceMergeAliases is true, and we didn't find a fromEntity, then something
// is wrong with storage. This function was called as part of an automated
// merge from CreateOrFetchEntity or Invalidate to repatriate an alias with its 'true'
// entity. As a result, the entity _should_ exist, but we can't find it.
// MemDb may be in a bad state, because fromEntity should be non-nil in the
// automated merge case.
if forceMergeAliases {
return fmt.Errorf("fromEntity %s was not found in memdb as part of an automated entity merge into %s; storage/memdb may be in a bad state", fromEntityID, toEntity.ID), nil, nil
}
return errors.New("entity id to merge from is invalid"), nil, nil
}