From 6a571b88abc1a7dc53c3bdf4c310c9ea0135ce06 Mon Sep 17 00:00:00 2001 From: orris-inc Date: Thu, 23 Apr 2026 16:22:47 +0800 Subject: [PATCH] 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. --- internal/application/node/usecases/updatenode.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/application/node/usecases/updatenode.go b/internal/application/node/usecases/updatenode.go index f171376..48178d7 100644 --- a/internal/application/node/usecases/updatenode.go +++ b/internal/application/node/usecases/updatenode.go @@ -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)