mirror of
https://github.com/orris-inc/orris.git
synced 2026-05-06 21:44:01 +08:00
fix: skip address/port uniqueness check when node address is empty
Align admin node update with the other three node usecases: an empty server address is a placeholder and must not participate in (address, port) uniqueness, otherwise two placeholder nodes sharing a port would wrongly collide on save.
This commit is contained in:
@@ -186,8 +186,9 @@ func (uc *UpdateNodeUseCase) Execute(ctx context.Context, cmd UpdateNodeCommand)
|
||||
if cmd.AgentPort != nil {
|
||||
newPort = int(*cmd.AgentPort)
|
||||
}
|
||||
// Only check if address or port actually changed
|
||||
if newAddress != existingNode.ServerAddress().Value() || newPort != int(existingNode.AgentPort()) {
|
||||
// Only check when address is non-empty and address or port actually changed.
|
||||
// An empty address is treated as a placeholder and must not participate in (address, port) uniqueness.
|
||||
if newAddress != "" && (newAddress != existingNode.ServerAddress().Value() || newPort != int(existingNode.AgentPort())) {
|
||||
exists, err := uc.nodeRepo.ExistsByAddressExcluding(ctx, newAddress, newPort, existingNode.ID())
|
||||
if err != nil {
|
||||
uc.logger.Errorw("failed to check address uniqueness", "error", err, "address", newAddress, "port", newPort)
|
||||
|
||||
Reference in New Issue
Block a user