From c70c8a6ec1044384cdaa0414df3722e2b96fb08d Mon Sep 17 00:00:00 2001 From: Pavel Sviderski Date: Sun, 10 Nov 2024 19:38:55 +1000 Subject: [PATCH] validate machine info before returning in ListMachine --- internal/machine/store/store.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/machine/store/store.go b/internal/machine/store/store.go index abdcbfdc..8bb7ff30 100644 --- a/internal/machine/store/store.go +++ b/internal/machine/store/store.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "google.golang.org/protobuf/encoding/protojson" + "log/slog" "uncloud/internal/corrosion" "uncloud/internal/machine/api/pb" ) @@ -77,6 +78,10 @@ func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error) { if err = protojson.Unmarshal([]byte(mJSON), &m); err != nil { return nil, fmt.Errorf("unmarshal machine info: %w", err) } + if err = m.Network.Validate(); err != nil { + slog.Error("Invalid network configuration for machine in store", "id", m.Id, "error", err) + continue + } machines = append(machines, &m) } return machines, nil