From 20762588b37dd454e9e9a64e4efc3b469e44ce0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Wed, 1 Apr 2026 16:39:59 +0200 Subject: [PATCH] container: fix deserialize HNS response in GetHNSEndpointStats (#2379) (#2380) Co-authored-by: Stefan L. <116070569+slab-msft@users.noreply.github.com> --- 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) {