From 1122a62aca278d0286f97ca0fcbb42d587f3a4f6 Mon Sep 17 00:00:00 2001 From: Julio Guerra Date: Fri, 16 Dec 2022 17:26:34 +0100 Subject: [PATCH] internal/remoteconfig: ignore empty update --- internal/remoteconfig/remoteconfig.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/remoteconfig/remoteconfig.go b/internal/remoteconfig/remoteconfig.go index fe3e36f4e5..0626466ecd 100644 --- a/internal/remoteconfig/remoteconfig.go +++ b/internal/remoteconfig/remoteconfig.go @@ -175,9 +175,19 @@ func (c *Client) updateState() { return } + respBody, err := io.ReadAll(resp.Body) + if err != nil { + log.Error("remoteconfig: http request error: could not read the response body: %v", err) + return + } + + if body := string(respBody); body == `{}` || body == `null` { + return + } + var update clientGetConfigsResponse - if err := json.NewDecoder(resp.Body).Decode(&update); err != nil { - log.Error("remoteconfig: http request: could not parse the json response body: %v", err) + if err := json.Unmarshal(respBody, &update); err != nil { + log.Error("remoteconfig: http request error: could not parse the json response body: %v", err) return }