From be644d75e5bc44e80177fa1e878ca201a66f7ac3 Mon Sep 17 00:00:00 2001 From: "Stefan L." <116070569+slab-msft@users.noreply.github.com> Date: Wed, 1 Apr 2026 16:35:37 +0200 Subject: [PATCH] container: fix deserialize HNS response in GetHNSEndpointStats (#2379) --- internal/headers/hcn/hcn.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/internal/headers/hcn/hcn.go b/internal/headers/hcn/hcn.go index 7e122d7a..38cdcdc1 100644 --- a/internal/headers/hcn/hcn.go +++ b/internal/headers/hcn/hcn.go @@ -75,13 +75,21 @@ func GetHNSEndpointStats(endpointID string) (EndpointStats, error) { return EndpointStats{}, err } - var stats EndpointStats + var response struct { + Success bool `json:"Success"` + Error string `json:"Error"` + Output EndpointStats `json:"Output"` + } - if err := json.Unmarshal([]byte(result), &stats); err != nil { + if err := json.Unmarshal([]byte(result), &response); err != nil { return EndpointStats{}, fmt.Errorf("failed to unmarshal JSON %s: %w", result, err) } - return stats, nil + if !response.Success { + return EndpointStats{}, fmt.Errorf("HNSCall failed: %s", response.Error) + } + + return response.Output, nil } func hnsCall(method, path, body *uint16) (string, error) {