From c2f268edec68d36c30b67d720e3e4e0047608446 Mon Sep 17 00:00:00 2001 From: Ioannis Dressos <96877388+idressos@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:16:01 +0300 Subject: [PATCH] Check GetAllocatedIPs error in client create/update --- handler/routes.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/handler/routes.go b/handler/routes.go index 3edf05f..978544b 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -475,6 +475,10 @@ func NewClient(db store.IStore) echo.HandlerFunc { // validate the input Allocation IPs allocatedIPs, err := util.GetAllocatedIPs("") + if err != nil { + log.Error("Cannot get allocated IP addresses: ", err) + return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get allocated IP addresses"}) + } check, err := util.ValidateIPAllocation(server.Interface.Addresses, allocatedIPs, client.AllocatedIPs) if !check { return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, fmt.Sprintf("%s", err)}) @@ -697,6 +701,10 @@ func UpdateClient(db store.IStore) echo.HandlerFunc { client := *clientData.Client // validate the input Allocation IPs allocatedIPs, err := util.GetAllocatedIPs(client.ID) + if err != nil { + log.Error("Cannot get allocated IP addresses: ", err) + return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Cannot get allocated IP addresses"}) + } check, err := util.ValidateIPAllocation(server.Interface.Addresses, allocatedIPs, _client.AllocatedIPs) if !check { return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, fmt.Sprintf("%s", err)})